Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 June, 2013, 04:09:09 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
  home news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

  Show Contributions
Pages: [1] 2
1  General Discussion / Computer Java Programming Help / function not getting called on: 19 February, 2013, 23:26:19
I have a strange problem in my current code: When I call Controls.requestKeyChange from MenuController.changeControls, it just seems to return from changeControls.

My code:

MenuController.java:

1
2
3
4
5
6
7
8
9
10
11
12
public class MenuController extends AbstractAppState implements ScreenController{
    //...
    public void changeControls(String s){
        ControlsButton1.setText("Press any button...");
        System.out.println("changeControls in MenuController called (Action: "+Controls.Action.values()[Integer.parseInt(s)]+" )");
        Controls.requestKeyChange(Controls.Action.values()[Integer.parseInt(s)], app.getInputManager(), new Runnable() {
            public void run() {
                ControlsButton1.setText(Controls.keyName);
            }
        });
    }
}

Controls.java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Controls implements ActionListener{
 
    //...
    public static void requestKeyChange(Action action,InputManager im, Runnable executeWhenDone){
       
        System.out.println("requestKeyChange called (Arguments: "+action+", "+im+", "+executeWhenDone);
       
        r = executeWhenDone;
        removeControls(im);
        setupKeyNames();
       
        for(int i=0; i<keyCodes.size(); i++){
            im.addMapping(keyNames.get(i), keyboard.get(i) ? new KeyTrigger(keyCodes.get(i)) : new MouseButtonTrigger(keyCodes.get(i)));
        }
       
        System.out.println(im.toString());
       
        changingControls = true;
    }
}

Console output:

1
2
3
4
//...
changeControls in MenuController called (Action: moveUp )
BUILD SUCCESSFUL (total time: 20 seconds)

Does anyone know why this happens?
2  Calculator Community / TI Z80 Calculator Projects / Racing game on: 16 June, 2012, 01:16:44
This is the project I've been working on since the start of the contest. I haven't done much yet because I'm busy with exams lately.

It is going to be a racing game in which you race against AI, and there will be some items you can use to go faster or to slow down other players (similar to mario kart).
It uses the 3D engine of my other game (Alien invasion), but this one is improved and supports textures, solid triangles and wireframe, instead of only textures.
This is what I have so far:

This is the track, which already works graphics-wise, but it hasn't got any collision checking yet. The track is fully wireframe (and will probably stay like that). The track is fully 3 dimensional, which means it can go left, right, up and down, but models for up and down haven't been created yet. The cube in the center of the screen is the placeholder for the car. The car will probably be mostly wireframe, to fit in the simulation-like theme of the track (of which the current name, 'cyber racer', comes).

Right now the graphics are quite bad, but I might add some models to the sides of the track as illustrations, if the speed will allow it when AI and items are added). Right now, it runs in 15MHz mode, and has 18 fps. But it still looks smooth.

I guess that's all I can say about it now.
For this project I can't include the source because of the rules of the contest. If you want to use the 3D engine in your own project, I can give you the engine of my previous project.
3  Calculator Community / ASM Language / optimizing asm code on: 17 April, 2012, 22:27:08
Hi,

I have to optimize this code, But I haven't really optimized before and whatever I try to do, I can't get it to work faster. Can anyone give me some tips?

Also: I'm optimizing for speed, not for size. The code can be quite big.

Here's the code itself:
Spoiler for code:

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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
DrawTriangle:
  ;IN: x1,y1,u1,v1,x2,y2,u2,v2,x3,y3,u3,v3
  ;scherm = 96*64

;the following code was used to add 100 to the x coordinates, to see if the sign was the problem

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  ld de, 100
;  ld hl, (x1)
;  add hl, de
;  ld (x1), hl
;  ld hl, (x2)
;  add hl, de
;  ld (x2), hl
;  ld hl, (x3)
;  add hl, de
;  ld (x3), hl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;---------------------------------------------------------------
; This part sorts the points so that Y1 <= Y2 <= Y3 so
; we can just draw each scanline below the last one.
;---------------------------------------------------------------

  ld hl, (x1)
  call Signed16To8
  ld h, $FF
  ld l, a
  ld (x1), hl
  ld hl, (x2)
  call Signed16To8
  ld h, $FF
  ld l, a
  ld (x2), hl
  ld hl, (x3)
  call Signed16To8
  ld h, $FF
  ld l, a
  ld (x3), hl

  ld hl, (y1)
  ld de, (y2)
  cpHLDE
  jr c, Y1SmallerThanY2

  ld hl, x1
  ld de, dx1 ;temp location
  ld bc, 6 ;size
  ldir

  ld hl, x2
  ld de, x1
  ld bc, 6
  ldir

  ld hl, dx1
  ld de, x2
  ld bc, 6
  ldir

Y1SmallerThanY2:
  ld hl, (y1)
  ld de, (y3)
  cpHLDE
  jr c, Y1SmallerThanY3

  ld hl, x1
  ld de, dx1 ;temp location
  ld bc, 6 ;size
  ldir

  ld hl, x3
  ld de, x1
  ld bc, 6
  ldir

  ld hl, dx1
  ld de, x3
  ld bc, 6
  ldir

Y1SmallerThanY3:
  ld hl, (y2)
  ld de, (y3)
  cpHLDE
  jr c, Y2SmallerThanY3

  ld hl, x2
  ld de, dx1 ;temp location
  ld bc, 6 ;size
  ldir

  ld hl, x3
  ld de, x2
  ld bc, 6
  ldir

  ld hl, dx1
  ld de, x3
  ld bc, 6
  ldir

Y2SmallerThanY3:

; +++++ End of sorting code +++++


;----------------------------------------------------------
; Here, some variables are initialized. The delta
; variables (the variables which start with a 'd')
; contain the values that need to be added to
; the variables which start with a 't'. Variables
; with a 't' and a '1' are used for the start of
; the scanline. Those with a 't' and a '2' are used
; for the end of the scanline.
;----------------------------------------------------------

  res 0, (IY) ;if this bit is 0, the routine is drawing the top half of the triangle. if it's 1, it's drawing the bottom half.
  res 1, (IY) ;This bit is used to store if the deltas for the texture coordinates inside scanlines are already calculated. They are constants, so they only need to be calculated once per half.

  ld hl, (y2)
  ld de, (y1)
  subFP ;This routine is for substracting fixed-point values, but here it's used to substract integer values.
  ld h, l
  ld l, 0
  push hl
  ld hl, (x2)
  ld de, (x1)
  subFP
  ld h, l
  ld l, 0
  pop de
  call DivFP
  ld (dx1), hl
  ld hl, (y3)
  ld de, (y2)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld hl, (x3)
  ld de, (x2)
  subFP
  ld h, l
  ld l, 0
  pop de
  call DivFP
  ld (dx2), hl
  ld hl, (y3)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld hl, (x3)
  ld de, (x1)
  subFP
  ld h, l
  ld l, 0
  pop de
  call DivFP
  ld (dx3), hl


  ld hl, (y2)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (u2)
  ld h, a
  ld l, 0
  ld a, (u1)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (du1), hl
  ld hl, (y3)
  ld de, (y2)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (u3)
  ld h, a
  ld l, 0
  ld a, (u2)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (du2), hl
  ld hl, (y3)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (u3)
  ld h, a
  ld l, 0
  ld a, (u1)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (du3), hl


  ld hl, (y2)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (v2)
  ld h, a
  ld l, 0
  ld a, (v1)
  ld d, a
  ld l, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (dv1), hl
  ld hl, (y3)
  ld de, (y2)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (v3)
  ld h, a
  ld l, 0
  ld a, (v2)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (dv2), hl
  ld hl, (y3)
  ld de, (y1)
  subFP
  ld h, l
  ld l, 0
  push hl
  ld a, (v3)
  ld h, a
  ld l, 0
  ld a, (v1)
  ld d, a
  ld e, 0
  subFP
  ;ld h, l
  ;ld l, 0
  pop de
  call DivFP
  ld (dv3), hl

  ld hl, (x1)
  bit 7, h
  jr z, TPos1
  ld (tx1+1),hl \ ld a, $FF \ ld (tx1),a
  ld (tx2+1),hl \ ld a, $FF \ ld (tx2),a
  jr TEnd1
TPos1:
  ld (tx1+1),hl \ xor a \ ld (tx1),a ;store the 16bit integer at hl into 16.8 fixed point number tx1
  ld (tx2+1),hl \ xor a \ ld (tx2),a
TEnd1:
  ld hl, (y1)
  ld (_ty), hl

  ld a, (u1)
  ld h, a
  ld l, 0
  ld (tu1), hl
  ld (tu2), hl
  ld a, (v1)
  ld h, a
  ld l, 0
  ld (tv1), hl
  ld (tv2), hl

;if Y1 == Y2, then we don't need to draw the first half.
  ld hl, (Y1)
  ld de, (y2)
  cpHLDE
  jp z, __TEndLoop

; +++++ End of initializing code +++++


;------------------------------------------------------------
; This is the loop in which the triangle is drawn.
; In each interval of the loop, a single scanline is
; drawn. When this loop finished, one half of the
; triangle is drawn.
;------------------------------------------------------------

TDrawLoop:
  ld a, (_ty)
  ld d, a
;if the Y of the scanline is negative, then go to the next one.
  bit 7, a
  jp nz, Clip
  ld a, (_ty)
;If it reaches the bottom of the screen, then stop drawing the triangle.
  cp 64
  ret nc

;Initialize variables for the scanline
  ld hl, (tu1)
  ld (tmpu), hl
  ld hl, (tv1)
  ld (tmpv), hl
  ld hl, (tu2)
  ld (temp2), hl
  ld hl, (tv2)
  ld (temp3), hl
  ld a, (tx2+1)
  ld (temp+1), a
  add a, 128
  ld b, a
  ld a, (tx1+1)
  ld (temp), a
  add a, 128
  cp b
  jr c, TOrdered
  ;jp po, TOrdered
  ld hl, (tu2)
  ld (tmpu), hl
  ld hl, (tv2)
  ld (tmpv), hl
  ld hl, (tu1)
  ld (temp2), hl
  ld hl, (tv1)
  ld (temp3), hl
  ld a, (tx2+1)
  ld (temp), a
  ld a, (tx1+1)
  ld (temp+1), a
TOrdered:
  ld l, d
  ld a, (temp)
;folowing line was for the test to see if the sign was the problem
  ;sub 100 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  bit 7, a
  jr z, TGetPixel
  xor a
TGetPixel:
  call GetPixel
  ld (mask), a
  ld (pointer), hl

;If the deltas for the texture coordinates inside a scanline are already
;calculated, then calculating them again is a wast of cycles.
  bit 1, (IY)
  jr nz, TPlotLoop
  ld hl, (tx1)
  ld de, (tx2)
  cpHLDE
  jr z, TPlotLoop
  ld a, (temp)
  ld h, a
  ld l, 0
  ld a, (temp+1)
  ld d, a
  ld e, 0
  subFP
  push hl
  ld hl, (tmpu)
  ld de, (temp2)
  subFP
  pop de
  call DivFP
  ld (tmpdu), hl
  ld a, (temp)
  ld h, a
  ld l, 0
  ld a, (temp+1)
  ld d, a
  ld e, 0
  subFP
  push hl
  ld hl, (tmpv)
  ld de, (temp3)
  subFP
  pop de
  call DivFP
  ld (tmpdv), hl
  set 1, (IY)


;---------------------------------------------------------------------
; In this loop, the scanline is drawn. One interval here
; draws one pixel. When the loop ends, one scanline is drawn.
;---------------------------------------------------------------------

TPlotLoop:
;If the x coordinate of the pixel is negative, then go to the next pixel.
  ld a, (temp)
  bit 7, a
  jr nz, TNoCarry

;if the pixel goes of the right side of the screen, then go to the next scanline
  cp 96
  jp nc, Clip

;Everything with 4 ;'s behind it are for 16x16 textures. Remove those and the
;textures will be 8x8.

  ld a, (tmpv+1)
  add a, a ;;;;
  ld hl, texture
  add a, l
  ld l, a

  ld a, (tmpu+1)
  bit 3, a ;;;;
  jr z, TFirstByte ;;;;
  res 3, a ;;;;
  inc hl ;;;;
TFirstByte: ;;;;
  ld b, a
  inc b
  ld a, (hl)
TshiftLoop:
  rla
  djnz   TshiftLoop
 
  ld a, (mask)
  ld hl, (pointer)
  jr c, TSetPixel

TResPixel:
  ;ld a, b
  cpl
  and (hl)
  ld (hl), a
  jr TEndPlot

TSetPixel:
  ;ld a, b
  or (hl)
  ld (hl), a

TEndPlot:
  ld hl, mask
  rrc (hl)
  jr nc, TNoCarry
  ld hl, (pointer)
  inc hl
  ld (pointer), hl
TNoCarry:

  ld hl, (tmpu)
  ld de, (tmpdu)
  add hl, de
  ld (tmpu), hl
  ld hl, (tmpv)
  ld de, (tmpdv)
  add hl, de
  ld (tmpv), hl

  ld a, (temp+1)
  ld b, a
  ld a, (temp)
  ld hl, temp
  inc (hl)
  cp b
  jp nz, TPlotLoop

; +++++ End of pixel plotting code +++++

;If it's drawing the secound half, then make it recalculate the thexture deltas
;for inside the scanlines. This was to solve a bug in the texture mapping.
  bit 0, (IY)
  jr nz, aaaa ;I suddenly ran out of inspiration for label names
;  res 1, (IY)
aaaa:

Clip:
  ld hl,(tx1)
  ld de, (dx1)
  ld a, d
  rla
  sbc a, a
  ld b, a
  add hl, de
  ld (tx1), hl
  ld a, (tx1+2)
  adc a, b
  ld (tx1+2), a

  ld hl,(tx2)
  ld de, (dx3)
  ld a, d
  rla
  sbc a, a
  ld b, a
  add hl, de
  ld (tx2), hl
  ld a, (tx2+2)
  adc a, b
  ld (tx2+2), a

  ld hl, (tu1)
  ld de, (du1)
  add hl, de
  ld (tu1), hl
  ld hl, (tu2)
  ld de, (du3)
  add hl, de
  ld (tu2), hl

  ld hl, (tv1)
  ld de, (dv1)
  add hl, de
  ld (tv1), hl
  ld hl, (tv2)
  ld de, (dv3)
  add hl, de
  ld (tv2), hl


  ld hl, (_ty)
  inc hl
  ld (_ty), hl
  ld de, (y2)
  cpHLDE
  jp c, TDrawLoop

;This is the end of the drawing loop
;If the secound half was drawn, then stop this routine.
  bit 0, (IY)
  jr nz, _TEnd

__TEndLoop:
  ;Here, some variables are initialized for drawing the secound half.

  ld hl, (y2)
  ld (_ty), hl

  ld hl, (y3)
  ld (y2), hl
  ld hl, (dx2)
  ld (dx1), hl
  ld hl, (du2)
  ld (du1), hl
  ld hl, (dv2)
  ld (dv1), hl

  ld hl, (x2)
  bit 7, h
  jr nz, TPos4
  ld (tx1+1),hl \ ld a, $FF \ ld (tx1),a
  jr TEnd4
TPos4:
  ld (tx1+1),hl \ xor a \ ld (tx1),a
Tend4:

  ld a, (u2)
  ld h, a
  ld l, 0
  ld (tu1), hl
  ld a, (v2)
  ld h, a
  ld l, 0
  ld (tv1), hl

  set 0, (IY)

  jp TDrawLoop

_TEnd:

  ret



getPixel:
   bit 7, a
   ret nz
   bit 7, l
   ret nz
   ld   h, 0
   ld   d, h
   ld   e, l
   
   add   hl, hl
   add   hl, de
   add   hl, hl
   add   hl, hl
   
   ld   e, a
   srl   e
   srl   e
   srl   e
   add   hl, de
   
   ld   de, PlotSScreen
   add   hl, de
   
   and   7
   ld   b, a
   ld   a, $80
   ret   z
   
   rrca
   djnz   $-1
   ret

note: I'm not asking to optimize it for me, but to help me optimize it, so I can learn from this and optimize better in the future.
4  General Discussion / General Technology and Hardware Discussion / calculator(84+) - arduino communication trough USB on: 08 April, 2012, 22:35:10
I wrote some communication routines to send bytes from an 84+ calculator to the arduino (not from arduino to calc).
Here is the example code:

z80:

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
.org $9D93
#define bcall(label) rst 28h \ .dw label

#include "ti83plus.inc"

.db t2ByteTok, tAsmCmp

  call USB_Init

  bcall(_GetKey)

  ;send 50
  ld b, 50
  call USB_SendByte

  ret

;------------------------------------------------
; calc-Arduino communication routines trough USB
;------------------------------------------------


USB_Init:
  ;initializes the USB connection

  ;turn the USB driver off so we can read and write manually
  bcall(810Eh) ;KillUSB

  ;put the D- line on low
  ld a, %00100000
  out ($4A), a

  ret


USB_SendByte:
  ;b = the byte to be send
  ld c, 0
  ;c = bitcounter

  call Wait

  ;set D- to high so the arduino knows we will send a byte
  ld a, %00011000
  out ($4A), a

  ;wait untill we can start sending the byte
  call Wait

SendLoop:
  ;put the bit we are going to send in carry
  rrc b

  jr c, sendOne

  ;send a 0
  ld a, %00100000
  out ($4A), a
  jr endBit

sendOne:
  ;send a 1
  ld a, %00011000
  out ($4A), a

endBit:
  ;increase the bit counter
  inc c

  ;stop sending if all 8 bits were sent
  ld a, c
  cp 8
  jr z, endSend

  call Wait
  jr sendLoop

endSend:
  ;set D- low so the arduino won't think we're trying to send an other byte
  ld a, %00100000
  out ($4A), a

  ret


;internally used routine(s)
;--------------------------

wait:
  ;waits untill you can send a bit

  ;if the clock is 0: wait untill it's 1
  in a, ($4D)
  bit 1, a
  jr z, Wait

waitLoop2:
  ;Wait untill the clock is 0, so we can begin writing
  in a, ($4D)
  bit 1, a
  jr nz, WaitLoop2

  ret

arduino

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

//Dp and Dm are the data kables of the USB
const int Dp = 5;
const int Dm = 6;
const int Delay = 1;

int RecievedByte = 0;
int Recieving = 0;
int RecievedBit = 0;
int Recieved = 0;
int ledOn = 0;

void setup(){
  pinMode(Dp, OUTPUT);
  pinMode(Dm, INPUT);
  pinMode(13, OUTPUT);
}


void loop(){
  digitalWrite(Dp, HIGH);
  //clock = 1 so we'll read a bit
  if(Recieving == 0){
    //if nothing is being sent, we have to check for a 1
    if(digitalRead(Dm) == HIGH){
      //1 was send, so we'll have to recieve a byte
      Recieving = 1;
      RecievedBit = 0;
      RecievedByte = 0;
    }
  } else {
    //save the received bit
    if(digitalRead(Dm) == HIGH){
      bitSet(RecievedByte, RecievedBit);
    } else{
      bitClear(RecievedByte, RecievedBit);
    }
    RecievedBit++;
    if(RecievedBit == 8){
      //if all 8 bits are sent, the byte is complete.
      Recieving = 0;
      Recieved = 1;
    }
  }
  delay(Delay);
  digitalWrite(Dp, LOW);
  if(Recieved){
    if(RecievedByte == 50){
      if(ledOn == 0){
        digitalWrite(13, HIGH);
        ledOn = 1;
      } else {
        digitalWrite(13, LOW);
        ledOn = 0;
      }
      RecievedByte = 0;
    }
    Recieved = 0;
  }
  delay(Delay);
}

HOW TO USE THE EXAMPLE PROGRAMS:
- BACKUP YOUR PROGRAMS AND OTHER IMPORTANT DATA ON YOUR CALC
- compile the z80 program (I used SPASM) and send it to your calc.
- send the programs to the arduino and the calc.
- if the arduino hasn't got an on-board LED, connect one (and a resistor!) to pin 13.
- cut a USB mini male end of a USB cable (make sure the wire attached to it is long enough, works with both A-type and B-type (both have been tested)).
- connect the white wire of the USB to pin 6, the green wire to pin 5 and the black wire to the GND.
- make sure the arduino is powered and insert the USB cable into the calc's USB port.
- run the assembly program with Asm( on the calc

When you run the program, press a key. The led should now turn on. When you run it and press a key again, the led should turn off. If your calc freezes, make sure the arduino is powered, the black wire is connected to the GND, runs the correct software and is connected to your calc.

What this does is: when you press a key on the calc, it sends a byte with a value of 50 to the arduino. The arduino notices a byte is send and checks if it's 50. If it's 50, pin 13 will toggle.

It may be very unoptimized (especially the arduino part, I learned the language two days ago), but it works. I hope this code can be usefull to anyone.

Also: thank you, Thepenguin77. Without your help, I wouldn't be able to control the USB port.
5  Calculator Community / TI Z80 Calculator Projects / [axe] 2D minecraft game on: 24 March, 2012, 01:02:59
During a few days of being bored while no computer was available, I started to make a game similar to minecraft in axe. Right now, you can only play in creative mode and save only one 24*25 world (can be easily changed in the scource code). It has got 9 blocks so far (the engine supports 15(air not included)), and sand will fall when there is no block underneath it (but only when it's visible). The world isn't generated yet, so you just start with an empty square of 22*23 blocks (edges are made of bedrock, which can't be broken to avoid corrupting memory).

Here's a screenshot showing it in action:
Spoiler for screenshot in spoiler because it causes a bit of lag:

If you want to play minecraft during class: here's a (DCS) executable:
http://dl.dropbox.com/u/11215358/MCWORLD2.8Xp

If you need an other shel or you want to see or modify the source:
http://dl.dropbox.com/u/11215358/MINESRC2.8Xp

Controls:
arrow keys: move
5: build mode (indicated by a black block at the right bottom of the screen)
2: break mode (indicated by the grey block at the right bottom of the screen)
+: next block (the current block is shown in the bottom right part of the screen)
-: previous block
1, ., 3, 4, 6, 8: place or break a block. 5 and 2 represent the character. The keys around it represent the places around the character. Press one of those keys to place or break a block in that place (depends of if you are in build mode or in break mode)
CLEAR: quit game. This will automatically save the world, but you will always start in the upper left corner of the world.

Bugs? Feature suggestions? comments? complaints? If you have them, please post them.
6  General Discussion / Computer Usage and Setup Help / Connect laptop to wifi on: 17 March, 2012, 01:24:04
I have an old laptop here, and it always connected to the internet using wifi well, but a few days ago, it suddenly stopped connecting. When I use thinkvantage acces connections, it can detect the network, but when it tries to configure an ip, it says 'connection failed'. Is there a way to fix this?
7  Calculator Community / TI Z80 Calculator Projects / polygon-based 3D engine (with textures) on: 11 December, 2011, 22:23:20
I have been working on a polygon-based 3D engine for a while, and the 3D itself works, and the textures work too, there are still some bugs, but I already know what is causing them.

This is how it looks like:


I decided to keep it open-scource. I'll try to update the source often.
The source code is included in the post. A compiled version is also included. If you use any code in your own project, you don't have to give me credits, and you can always ask for help for using it on this topic.

Source is not fully commented, but I'll try to do that in a few days.

Credits:

This is everybody who helped me:
Hot_Dog
jacobly
thepenguin77
timoty
Runer112
leafiness0
Builderboy
Qwerty.55
t0xic_kitt3n
ztrumpet
calc84maniac
shmibs
p2
chattahippie
christop (cemetech)
KermMartian (cemetech)
benryves (cemetect)
Dr. Best (Ultimate 3D)

If you helped me but I forgot to ad you, please tell. If I put you in this list but you don't want to be in the credits,please tell too.
8  Calculator Community / ASM Language / clipping on: 05 November, 2011, 00:59:30
I'm trying to make my triangle drawing code clipped, but I must be doing something wrong becouse the buffer overflows which corrupts some flags of the OS.

here's the code that should clip horizontally

1
2
3
4
5
  ld a, (temp)
  bit 7, a
  jr nz, TEndPlot
  cp 95
  jp nc, Clip
temp is the var that contains the x position of the pixel that will be drawn.
TEndPlot is a label that is behind the code to plot the pixel, so jumping to here doesn't draw the current pixel.
Clip is a label that wen jumped too will stop drawing the current scanline, and prepares for the next one.

Here's the code that should clip vertically:

1
2
3
4
5
  bit 7, a
  jp nz, Clip
  ld a, (_ty)
  cp 64
  ret nc
_ty is the y coordinate of the scanline that will be drawn.
Clip stops the current scanline (so nothing will be drawn) and prepares the next one.
ret obiously ends the drawing routine.

Many thanks in advance.
9  General Discussion / Computer Projects and Ideas / Base Converter (also works for signed and fixed-point numbers) on: 21 October, 2011, 22:17:35
Everybody who programs z80 or an other low-level programming language has to do a lot of converting between decimal, binary and hexadecimal numbers. This can easily be done by using the windows calculator with normal integers, but when you use signed integers or fixed-point numbers, it gets harder, and takes more time to calculate them. Because I have to do that a lot, I decided to make a tool which can convert all kinds of binary, hexadecimal and decimal numbers to each other, including fixed-point and signed numbers, and I thought this might be useful to other people too, so I decided to distribute it.

It's easy to use it: You just select the base of the input and output, you check if the numbers are signed, select the form (integer or fixed-point) and click the convert key.

For now, the number of bits is ignored, so you may have to use only the last few characters ore add prefix zero's, but it can

And here's the link to the program itself:
http://dl.dropbox.com/u/11215358/base%20converter.jar
It's a java program and uses no libraries, so it should work on all operating systems, when java is installed.

Do you find bugs or do you have problems with this program? please post. If you find this program completely useless and you think I shouldn't have distributed it, please post too.
10  Calculator Community / ASM Language / 16 by 24 bit signed addition on: 02 October, 2011, 21:24:44
Hi,

I'm trying to do a 16 by 24bit signed addition for my z80 program. Now I have this code:

1
2
3
4
5
6
7
8
9
10
  ld hl,(var1)
  ld de, (var2)
  ld a, h
  rla
  sbc a,a
  add hl, de
  ld b, a
  ld a, (var1+2)
  adc a, b
  ld (var1+2), a
It seems to work in some situations, but it also sometimes gives other results.
What am I doing wrong?

btw: var1 is the 24bit var, var2 the 16bit one. I haven't fully written this routine, a part of it comes from a load 16bit to 24bit routine from calc84maniac.

many thanks in avantage.
11  General Discussion / Math and Science / interpolation on: 30 July, 2011, 00:02:02
I want to calculate the value of a point, based on the position of the point between 4 other points with each an other value.
an image to illustrate what I'm trying to say:

In this image, there are 4 points with a given value of a and a point between those 4 points which has got an unknown value of a. I now want to know how i can calculate value a of that point, based on the position of that point so that when x=x1 and y=y1, a=a1=1, and when x=x2 and y=y2, a=a2=2, and so on. And when point (x,y) is in the middle of (x1,y1) and (x2,y2), a should be the average of a1 and a2, so a=1.5.

Is there a formula which i can use to interpolate the a value of a point between the a values of the other points?
12  General Discussion / Computer Projects and Ideas / Back to cretaceous on: 20 July, 2011, 20:09:09
Back to Cretaceous is a java game which i'm working at with a few friends. The engines are almost done, so now we have to start working at the graphical part. There is still one problem: We can't agree on how the dinosaurs wil look like, so we decided to append a poll. There are three possibilities:
 - Scales: The dinosaurs will have a scaled skin, which will make them look like giant reptiles. This is how almost everybody thinks abouth dinosaurs.
 - Feathers: Te dinosaurs will have feathers, which will make them look more like birds. Recent investigation has proved that some small dinosaurs had feathers. Weather the big dinosaurs had feathers is still uncertain.
 - A mix of the two: small dinosours will have feathers (becouse that's proven) and the big ones will still look like giant reptiles (becouse that's how everybody thinks abouth dinosaurs).

I'm not saying which one I prefer becouse that could have influence on the results, which isn't fair, so please don't ask for it.
13  General Discussion / Computer Java Programming Help / Setting the background of a JFrame on: 16 July, 2011, 16:52:48
I'm trying to set the background color of an undecorated JFrame to black, but the SetBackground methot does nothing.

My Window creation code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
JFrame.setDefaultLookAndFeelDecorated(true);
    Loading = new JFrame("");
    Loading.setAlwaysOnTop(true);
    Loading.setLayout(null);
    Loading.setUndecorated(true);
    Loading.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
    JLabel LoadingText = new JLabel("Loading... - Please wait.");
    LoadingText.setBounds(250,0,500,15);
    LoadingText.setHorizontalAlignment((int)JFrame.CENTER_ALIGNMENT);
    LoadingText.setForeground(Color.WHITE);
    LoadingBar.setMinimum(0);
    LoadingBar.setMaximum(100);
    LoadingBar.setValue(0);
    LoadingBar.setForeground(Color.GREEN);
    LoadingBar.setBackground(Color.RED);
    LoadingBar.setBounds(0,30,1000,30);
    Loading.getContentPane().add(LoadingText);
    Loading.getContentPane().add(LoadingBar);
    Loading.setBounds(Toolkit.getDefaultToolkit().getScreenSize().width/2-500,Toolkit.getDefaultToolkit().getScreenSize().height/2-100,1000,200);
    Loading.setBackground(Color.BLACK);
    Loading.setFocusable(true);
    Loading.setVisible(true);

And this is the result:


You can see that the SetBackground method hasn't done anything. Is there a way to make the background of a JFrame black?
14  Calculator Community / ASM Language / Texture drawing on: 13 June, 2011, 22:29:29
Does anybody knows how to draw repeated textures? It would help a lot at my 3D engine, which now can only render wireframe.

I only need to know how it's done, so I can write my own routine.

What I mean with textures: this is a wire frame rectangle rendered by my 3D Engine:

I want to draw a sprite between those 4 points. Could someone explain the principle behind this please?
15  Calculator Community / ASM Language / an other assembly question on: 05 June, 2011, 01:33:52
I don't really get this:

Clears ramdoesn't clear the ram

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  ld hl, (screenx)
  ld d, 1
  ld e, 0
  call SubFP
  ld b, h \ ld c, l
  ld de, 94
  call MulFP
  ld (screenx), hl
  ld hl, (screeny)
  ld d, 1
  ld e, 0
  call SubFP
  ld b, h \ ld c, l
  ld de, 62
  call MulFP
  ld (screeny), hl
  ret

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  ld hl, (screenx)
  ;ld d, 1
  ;ld e, 0
  call SubFP
  ld b, h \ ld c, l
  ld de, 94
  call MulFP
  ld (screenx), hl
  ld hl, (screeny)
  ;ld d, 1
  ;ld e, 0
  call SubFP
  ld b, h \ ld c, l
  ld de, 62
  call MulFP
  ld (screeny), hl
  ret

In the left part, it clears the ram, while in the right part, it doesn't clear the ram while i have only comented out a few ld commands.

coul someone help please?
Pages: [1] 2
Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.657 seconds with 27 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.