Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
24 May, 2013, 03:30:46 *
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 3 4
1  General Discussion / Math and Science / Three intersecting parabolas on: 04 May, 2012, 02:01:19
I've been thinking about this all day and I can't figure it out...

Say you have three known points p0, p1, and p2. Each of these points serves as the focus of a parabola, and all three parabolas share a single line at y=d as their directrix. Assume that d is such that all three parabolas open in the same direction, and assume that the three foci do NOT all lie on a single line parallel to the directrix.

So the idea is to solve for value of d that makes all three parabolas intersect at a single point. There should only be one value that makes this true.

Basically, so far I've got quite a bit conceptually figured out in terms of what needs to happen...but I don't really know how to make it happen.

Here's kinda what I have:



The intersection point(s) of two parabolas (zn)can be calculated fairly easily:
z0=a0x2+b0x+c0
z1=a1x2+b1x+c1

Find the quadratic equation that is the difference of the two, and set it equal to zero:
0=(a0-a1)x2+(b0-b1)x+(c0-c1)
Use the quadratic formula to find the zeros:
x=(-(b0-b1)±√((b0-b1)2-4(a0-a1)(c0-c1)))/2(a0-a1)



A parabola can also be written as (x-h)2=4p(y-k), where (h,k) is the vertex of the parabola, (h,k+p) is the focus, and the directrix lies at y=k-p
With a focal point F and a directrix at y=d, all other necessary variables can be calculated as follows:
p=(Fy-d)/2
h=Fx
k=Fy-p
a=1/4p
b=-h/2p
c=h2/4p+k


Through this, all variables can be simplified down to only use F and d:
a=1/2(Fy-d)
b=-Fx/(Fy-d)
c=Fx2/2(Fy-d)+Fy-(Fy-d)/2[/tt]

So you could technically write out the equation of a parabola as
y = x2/2(Fy-d)   +   -Fxx/(Fy-d)   +   Fx2/2(Fy-d)+Fy-(Fy-d)/2



As you can see, it gets pretty hectic pretty quickly. For example, the quadratic formula would then be:
x=(Fx/(Fy-d)±√((-Fx/(Fy-d))2-(2/(Fy-d))(Fx2/2(Fy-d)+Fy-(Fy-d)/2)))/(1/(Fy-d))


Remember, this needs to be solving for d...

Really, I don't know where to go from here. Anyone have any insight?


---EDIT:
Okay, so I'm slowly figuring things out.

The equation is crazy complex, but you have to solve for the intercepts of two parabolas, then plug that quadratic formula calculation in for X in one of those equations, and set it equal to the equation for the third parabola with the quadratic formula calculation plugged in for X as well.

a2((-(b0-b1)±√((b0-b1)2-4(a0-a1)(c0-c1)))/2(a0-a1))2+b2((-(b0-b1)±√((b0-b1)2-4(a0-a1)(c0-c1)))/2(a0-a1))+c2=a0((-(b0-b1)±√((b0-b1)2-4(a0-a1)(c0-c1)))/2(a0-a1))2+b0((-(b0-b1)±√((b0-b1)2-4(a0-a1)(c0-c1)))/2(a0-a1))+c0

Looks like fun, right? Now substitute the As, Bs, and Cs with their F/d equivalents that I mentioned earlier, accounting for the fact that the Fs have to be Fnx and Fny for each variable of the corresponding n value.
2  Calculator Community / The Axe Parser Project / [Axiom] Advanced Graphics [in development] on: 27 February, 2012, 23:02:50
This has been in the works for a few weeks now, so I thought I'd make a thread about it.

I began writing this Axiom with a fixed-memory flood fill routine, but I failed miserably. I finally convinced jacobly to give it a try. Together we completely optimized the algorithm and he was able to write an awesomely optimized version. Then I started working on a filled circle algorithm, which jacobly volunteered to convert to Axiom format for me, but a few *cough* bugs were found. He has since been working with me to fix those bugs. All-in-all, this is basically an Axiom by both jacobly and myself.

This Axiom will be a collection of more advanced graphics routines which we hope will be greatly useful for graphics programs, and potentially games as well. Some of the routines will definitely NOT be useful for games, due to speed issues.

Currently written:
  • Fixed-Memory Flood Fill (needs optimization)
"Fixed-memory" means there is no risk for stack overflow AT ALL. However, the routine is subsequently very slow, so it will not be suitable for games or anything that needs fast dynamic area filling. It would be fine for a "paint bucket" tool in most on-calc graphics programs though. This will *hopefully* support grayscale filling as well.
  • Filled Circles (aaalmost done)
Fully clipped filled circle routine with variable buffer and variable fill type (on/off/invert) using numerical arguments.

Kinda sorta planned:
  • Vertical/Horizontal Line Segments (on/off/invert)
  • Clipped Lines (on/off/invert)
  • Rectangles (on/off/invert)
  • Rectangle outlines (on/off/invert)
  • Ellipses?

Any other suggestions for what this axiom could have?
3  General Discussion / Computer Projects and Ideas / Fixed-Memory Flood Fill Pseudocode on: 10 February, 2012, 09:56:04
So, I was trying to write an assembly program to execute a fixed-memory flood fill routine as described by the "flood fill" Wikipedia article here, but I realized that the algorithm written there is poorly explained, and also missing a lot of crucial conditions.

After realizing this, I opened up Adobe Flash to try to write an implementation so that I could easily see what was going on at all times, and could therefore debug it a lot more easily.

After hours of debugging and modifications, I finally was able to write an algorithm that actually worked in all situations. Here is the pseudocode I have written out for it:


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
RULE is "right"
FINDLOOP is false
BOTTLENECK is false

CUR is the current pixel
MARK is the first mark, and is not set
MARK2 is the second mark, and is not set

main loop:
if CUR is bound by 4 edge pixels
paint CUR
all possible pixels have been filled, so exit the routine
 
if CUR is bound by 3 edge pixels
paint CUR
move based on RULE
continue main loop

if CUR is bound by 2 edge pixels
if the two bounding edge pixels are not across from each other, and the corner opposite both edge pixels is not filled
paint CUR
move according to RULE
continue main loop
else
if RULE is "right" and  MARK is not set
set MARK to CUR's location and direction
set FINDLOOP to false
else, if MARK is set
if MARK2 is not set
if CUR is at MARK's location
if CUR's direction is the same as MARK's
remove MARK
set RULE to "right"
else
set RULE to "left"
set CUR to MARK's direction
set FINDLOOP to false
else, if FINDLOOP is true
set MARK2 to CUR's location and direction
else
if CUR is at MARK's location
set CUR to MARK2's direction and location
remove MARK
remove MARK2
set RULE to "right"
else if CUR is at MARK2's location
set MARK to MARK2's direction and location
set CUR's direction to MARK2's direction
remove MARK2
if RULE is "right" and MARK is not set
if BOTTLENECK is false
paint CUR
set BOTTLENECK to false
move according to RULE
continue main loop

if CUR is bound by 1 edge pixel
if RULE is "left" and FINDLOOP is false
set FINDLOOP to true
else, if neither  of the corners opposite the bounding pixel are filled
paint CUR
move according to RULE
continue main loop

if CUR is bound by 0 edge pixels
if RULE is "left" and FINDLOOP is false
set FINDLOOP to true
set BOTTLENECK to false
move any direction (use a default direction, not a random one)
continue main loop


##############################
how to move according to RULE:
if CUR is filled or the rule-side-corner is filled
move CUR one step forward
else
if MARK is at the pixel one step forward
set BOTTLENECK to true
else, if MARK2 is at the pixel one step forward
set MARK to MARK2's direction and location
set CUR's direction to MARK2's direction
remove MARK2
if RULE is "left" and FINDLOOP is false
if either the pixel two steps forward is filled or the non-rule-side pixel is filled
set FINDLOOP to true
move CUR one step forward
move CUR one step to the RULE side



##############################
every time you paint:
remove MARK, if set
remove MARK2, if set
set FINDLOOP to false
set BOTTLENECK to false
set RULE to "right"

I'd like to put this into the Wikipedia article so that people can have a much better example to base their code on. Is there any way I should modify this pseudocode to make it look better?

I am also going to create some images explaining what some things are (like what an "open corner" is, as opposed to a "closed corner").

Also, if someone wants to write an ASM implementation of this, please go ahead. I bet your implementation would be better than mine >.<
4  Calculator Community / ASM Language / Fixed-Memory Flood Fill debugging on: 08 February, 2012, 10:39:36
For a while now I've been thinking about writing a fixed-memory flood fill routine. I finally wrote one out....but it doesn't work. I'm not very good at using the wabbitemu debugger, so debugging this is turning into an incredibly difficult job for me. I was wondering if someone could help me look through this and see if they can't assist me in figuring out what's wrong. I can try to clarify any questions you have in any parts of the routines.

Note that this is mostly optimized for speed because of the inevitably slow speed of this flood fill method.

EDIT: I attached a screenshot of what it does right now if you just execute it.

EDIT2: I made some modifications to the routine, but it's still buggy. The screenshot is not entirely accurate anymore. Now is' basically doing the same thing, only to the right of pxl(10,10) rather than to the left of it...

EDIT3: Updated the explanation of how the "right hand rule" should be followed at the bottom of my pseudocode. It should make more sense now...

I wrote this routine based off of the fixed memory flood fill routine loosely described here:
http://en.wikipedia.org/wiki/Flood_fill#Fixed_memory_method_.28right-hand_fill_method.29

I first wrote up this pseudocode:

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
This algorithm:
http://en.wikipedia.org/wiki/Flood_fill#Fixed_memory_method_.28right-hand_fill_method.29

RULE = right
MARK = null
MARKDIR = null
FINDPASSAGE = false
-----

if 4 bounds painted
        paint cur
        stop
else if 3 bounds painted
        MARK = null
        FINDPASSAGE = false
        RULE = right
        paint cur
        move to open bound
        
//#######################    
else if 2 bounds painted
        if MARK == null && RULE == right
                MARK = cur
                MARKDIR = dir
                FINDPASSAGE = false
        else if cur == MARK
                if dir == MARKDIR
                        MARK = null
                else
                        RULE = left    //.....this stuff here is the "oh no I'm in a loop" stuff.
                        dir = MARKDIR
                        MARK = null
                        FINDPASSAGE = false
                        
        if MARK == null && RULE == right
                paint cur
        move based on RULE         //after moving
                                                //set "dir" to the next direction
                                                //according to RULE (right hand rule or left hand rule)

//######################
                
else if 1 bound painted
        if RULE == left  //then we're in a loop, and this triggers the second stage
                FINDPASSAGE = true
        else
                if both opposite corners are open && MARK == null
                        paint cur
        move base on RULE
else if 0 bounds painted
        if RULE == left
                FINDPASSAGE = true
        paint cur?
        move anywhere :P
        

========================================
   How do you follow the right hand rule? Which is next?

           (Key: _ = empty pixel, # = filled pixel, 0 = current position and direction)
if the corner is filled, just move forward
        ___
        _0_
        _##
...becomes...
        ___
        __0
        _##
but if the corner is empty, there are two possible ways to move
        ___
        _0_
        _#_
first possibility
        ___
        _#0        If the current pixel is painted before moving, move here
        _#_
second possibility
        ___
        ___        if the pixel is NOT painted before moving, move around the corner to the next edge
        _#0        because just going straight would make it now have no borders...



Based on that I wrote my assembly program, which is quite messy, I'm sorry to say...


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
#include    "ti83plus.inc"
#define     progStart   $9D95
.org        progStart-2
.db         $BB,$6D

;these are all flags used in the "bools" address. I didn't use one of the AsmFlags addresses, because that might be in use by whatever program uses this routine.
bool_color .equ 0 ;unused for now. only fills black.
bool_color2 .equ 1 ;unused for now
bool_rule .equ 2 ;set=right-hand rule,reset=left-hand rule
bool_findpath .equ 3 ;set if
bool_filled .equ 4 ;whether or not the current pixel has been filled. This is set when paintCur is called
bool_mark .equ 5 ;if reset, mark is null. otherwise, mark is in use. Used in the main loop


_init:
ld (save_iy),iy
ld iy,bools
ld hl,(cx)
call getPixel
and (hl)
ret nz ;quit if the current pixel is already filled
_main: ;main program loop.
call safecopy ;safecopy exists for testing purposes only.
res bool_filled,(iy)
ld hl,(cx)
call getEdgePixels
ld (bounds), a
;ld (PlotSScreen),a
call SumNibBits
ld b,a
djnz _not1
_1_bound:
bit bool_rule,(iy)
jr nz,+_
set bool_findpath,(iy)
jr ++_
_:
bit bool_mark,(iy)
jr nz,+_
ld hl,(OppCornMask_LUT)
ld d,0
ld e,(iy+off_cdir)
add hl,de
ld a,(bounds)
and (hl)
jr nz,+_
call paintCur
_:
call MoveByRule
_not1:
djnz _not2
_2_bound:
;if MARK == null && RULE == right
bit bool_mark,(iy)
jr nz,_2elseif
;MARK = cur
ld hl,(cx)
ld (mx),hl
;MARKDIR = dir
ld a,(cdir)
ld (mdir),a
;FINDPASSAGE = false
res bool_findpath,(iy)
set bool_mark,(iy) ;mark is not null
_2elseif:
;else if cur == MARK
ld hl,(cx)
ld a,(mx)
cp l
jr nz,_2if
;if dir == MARKDIR
ld a,(my)
cp h
jr nz,_2if
ld a,(cdir)
ld hl,mdir
cp (hl)
jr nz,_2else
;MARK = null
res bool_mark,(iy)
jr _2if
_2else:
;else
;RULE = left
res bool_rule,(iy)
;dir = MARKDIR
ld a,(hl)
ld (cdir),a
;MARK = null
res bool_mark,(iy)
;FINDPASSAGE = false
res bool_findpath,(iy)
call TurnByRule
_2if:
;if MARK == null && RULE == right
bit bool_mark,(iy)
jr nz,_move
bit bool_rule,(iy)
jr z,_move
;paint cur
call paintCur
;move based on RULE
_move:
call MoveByRule
jp _main
_not2:
djnz _not3
_3_bound:
res bool_mark,(iy)
res bool_findpath,(iy)
set bool_rule,(iy)
call TurnByRule
call paintCur
call MoveByRule
jp _main
_not3:
djnz _not4
_4_bound:
;4 bound
call paintCur
ld iy,(save_iy)
ret ;;QUIT
_not4:
_0_bound:
ld hl,cdir
ld (hl),0
call paintCur
inc hl
inc (hl) ;increase cx
jp _main



bools:
.db 0 | (1 << bool_color) | (1 << bool_color2) | (1 << bool_rule)
cdir: ;current dir. 0=down, 1=left, 2=up, 3=right
.db 0
cx: ;current x. Set to 10 for testing
    .db 10
cy: ;current y. Set to 10 for testing
    .db 10
mdir: ;mark dir
    .db 0
mx: ;mark x
    .db 0
my: ;mark y
    .db 0
bounds: ;holds the bound data
    .db 0 ;bit order: FAHCGDBE
;ABC ;here's how that order lines up with surrounding pixels
;DxE
;FGH
save_iy:
.dw 0

;I reference these using IY+* to load values into other registers. IY points to bools.
;Not all of these are used. In fact, I think only off_cdir is used.
off_cx .equ cx-bools
off_cy .equ cy-bools
off_cdir .equ cdir-bools
off_mx .equ mx-bools
off_my .equ my-bools
off_mdir .equ mdir-bools
off_bounds .equ bounds-bools


;masks for the pixel straight forward, based on dir
.db %00001000, %00000100, %00000010, %00000001
FrontByDirMask_LUT:
; %FAHCGDBE %FAHCGDBE %FAHCGDBE %FAHCGDBE
.db %00001000, %00000100, %00000010, %00000001
.db %00001000, %00000100, %00000010, %00000001

OppCornMask_LUT: ;masks for the two opposite corners from the edges corresponding with FrontByDirMask_LUT
; %FAHCGDBE %FAHCGDBE %FAHCGDBE %FAHCGDBE
.db %01010000, %00110000, %10100000, %1100000

FrontCornRightRuleMask_LUT: ;masks for corners forward/right, based on cdir
; %FAHCGDBE %FAHCGDBE %FAHCGDBE %FAHCGDBE
.db %10000000, %0100000, %00010000, %0010000

FrontCornLeftRuleMask_LUT: ;masks for corners forward/right, based on cdir
; %FAHCGDBE %FAHCGDBE %FAHCGDBE %FAHCGDBE
.db %00100000, %1000000, %01000000, %00010000

.db 1
DirMoveX_LUT: ;LUT for X offsets based on dir. Used in MoveByRule.
.db 0,-1,0
DirMoveY_LUT:
.db 1,0,-1,0


MoveByRule: ;move based on the rule. (this immediately goes into TurnByRule)
bit bool_filled,(iy)
ld e,(iy+off_cdir)
ld d,0
jr z,_moveforward
bit bool_rule,(iy)
ld b,d
ld c,1
ld hl,FrontCornRightRuleMask_LUT
jr z,+_
ld c,-1
ld hl,FrontCornLeftRuleMask_LUT
_:
ld e,(iy+off_cdir)
ld d,b
add hl,de
ld a,(bounds)
and (hl)
jr nz,_moveforward
ld hl,DirMoveX_LUT
add hl,de
add hl,bc
ld a,(cx)
add a,(hl)
ld (cx),a
inc hl
inc hl
inc hl
ld a,(cy)
add a,(hl)
ld (cy),a
_moveforward:
ld hl,DirMoveX_LUT
add hl,de
ld a,(cx)
add a,(hl)
ld (cx),a
inc hl
inc hl
inc hl
ld a,(cy)
add a,(hl)
ld (cy),a


TurnByRule: ;turn based on the rule.
ld hl,FrontByDirMask_LUT
ld d,0
ld e,(iy+off_cdir)
add hl,de
ld e,1
bit bool_rule,(iy)
jr nz,+_
ld e,-1
_:
ld b,(iy+off_bounds)
xor a
ld c,a
_frontloop:
;while front on, rotate opposite from rule
;check front
ld a,b
and (hl)
jr z,_sideloop
dec c
sbc hl,de
jr _frontloop
_sideloopskip:
inc c
_sideloop:
add hl,de
ld a,b
and (hl)
jr z,_sideloopskip
ld a,(cdir)
dec e
jr nz,_leftrotate
add a,c
and 3
ld (cdir),a
ret
_leftrotate:
sub c
and 3
ld (cdir),a
ret



SumNibBits:
;Thank you, Runer112, for this routine
;returns the sum of the lower 4 bits of A
;output: A = sum of bits
;destroys HL
and %00001111
ld hl,SumNibBits_LUT
add a,l
ld l,a
ld a,(hl)
ret nc
inc h
ld a,(hl)
ret
SumNibBits_LUT:
.db 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4
;.db 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5



getPixelByte:
;standard first part of a getPixel routine. Retrieves the byte of the pixel in HL
ld a,h
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
ret

getPixel:
;just a getPixel routine. Nothing to see here.
call getPixelByte
and 7
ld b,a
ld a,$80
ret z
rrca
djnz $-1
ret

paintCur:
;fills the current pixel (cx,cy) and sets the "bool_filled" flag
ld hl,(cx)
call getPixel
or (hl)
ld (hl),a
set bool_filled,(iy)
ret

getEdgePixels:
;get all 8 surrounding pixels and put them into A in the order specified at the "bounds" label.
push hl ;save x,y for checking offset later
call getPixelByte
push hl
pop ix

and 7
jr z,_specLeft
cp 7
jr z,_specRight
dec a ;get the surrounding bits into the 3 msb of C, D, and E
ld b,a
ld d,(ix-12)
ld e,(ix+12)
ld a,(hl)
jp z,CheckOffScreen
ld c,b
ld a,e
rrca
djnz $-1
ld e,a
ld b,c
ld a,d
rrca
djnz $-1
ld d,a
ld b,c
ld a,(hl)
rrca
djnz $-1 ;d=ABC00000;a=DXE00000; e=FGH00000
ld c,a
jp CheckOffScreen
_specLeft: ;special-case for left-side overflow
ld d,(ix-12)
ld a,(ix-13)
rra
rr d
ld e,(ix+12)
ld a,(ix+11)
rra
rr e
ld c,(hl)
dec hl
ld a,(hl)
rra
rr c
jp CheckOffScreen
_specRight: ;special-case for right-side overflow
ld d,(ix-11)
ld a,(ix-12)
rl d
rra
rra
rra
ld e,(ix+13)
ld a,(ix+12)
rl e
rra
rra
rra
ld a,(hl)
inc hl
ld c,(hl)
rl c
rra
rra
rra
ld c,a

CheckOffScreen:
pop hl ;recall x,y
ld a,l
dec a
cp 62
jr c,_testx
jr z,_fixtop
jr _fixbtm
_fixtop:
ld e,%11100000
jr _testx
_fixbtm:
ld d,%11100000
_testx:
ld a,h
dec a
cp 94
jr c,EdgePixelCombine
jr z,_fixright
jr _fixleft
_fixright:
set 5,c
set 5,d
set 5,e
jr EdgePixelCombine
_fixleft:
set 7,c
set 7,d
set 7,e
EdgePixelCombine:
;Thank you, Runer112, for this routine
;d=ABC00000
;c=DXE00000
;e=FGH00000
ld a,c
xor d
and %10111111
xor d ;a=DBE00000
rlca
rlca ;a=00DBE000
xor e
and %10111111
xor e ;a=0GDBE000
rrca
rrca ;a=000GDBE0
xor d
and %01011111
xor d ;a=ABCGDBE0
rrca ;a=0ABCGDBE
xor e
and %01011111
xor e ;a=FAHCGDBE
ret






;-----> Copy the gbuf to the screen, guaranteed
;Input: nothing
;Output:graph buffer is copied to the screen, no matter the speed settings
;
;in f,(c) is an unofficial instruction.
;It must be noted that you cannot specify any other register. Only f works.
;You may have to add it in order for the routine to work.
;if addinstr doesn't work, you may manually insert the opcodes .db 0EDh,070h

 .addinstr IN F,(C) 70ED 2 NOP 1

SafeCopy:
;di                 ;DI is only required if an interrupt will alter the lcd.

ld hl,PlotSScreen  ;This can be commented out or another entry placed after it
                           ;so the buffer can be provided by option.
ld c,$10
ld a,$80
setrow:
in f,(c)
jp m,setrow
out ($10),a
ld de,12
ld a,$20
col:
in f,(c)
jp m,col
out ($10),a
push af
ld b,64
row:
ld a,(hl)
rowwait:
in f,(c)
jp m,rowwait
out ($11),a
add hl,de
djnz row
pop af
dec h
dec h
dec h
inc hl
inc a
cp $2c
jp nz,col
ret
5  General Discussion / General Technology and Hardware Discussion / Autonomous Quadrotors on: 01 February, 2012, 13:58:55
I thought some people might enjoy these.

<a href="http://www.youtube.com/watch?v=YQIMGV5vtd4" target="_blank">http://www.youtube.com/watch?v=YQIMGV5vtd4</a>
<a href="http://www.youtube.com/watch?v=MvRTALJp8DM" target="_blank">http://www.youtube.com/watch?v=MvRTALJp8DM</a>
<a href="http://www.youtube.com/watch?v=geqip_0Vjec" target="_blank">http://www.youtube.com/watch?v=geqip_0Vjec</a>
<a href="http://www.youtube.com/watch?v=S-dkonAXOlQ" target="_blank">http://www.youtube.com/watch?v=S-dkonAXOlQ</a>
6  General Discussion / Miscellaneous Discussion / Rube Goldberg Machines on: 18 January, 2012, 10:23:34
I'll just leave these here. (I'm sure you've seen a few of them already)

<a href="http://www.youtube.com/watch?v=GOMIBdM6N7Q" target="_blank">http://www.youtube.com/watch?v=GOMIBdM6N7Q</a>
<a href="http://www.youtube.com/watch?v=qybUFnY7Y8w" target="_blank">http://www.youtube.com/watch?v=qybUFnY7Y8w</a>
<a href="http://www.youtube.com/watch?v=1kvdq8cRNBM" target="_blank">http://www.youtube.com/watch?v=1kvdq8cRNBM</a>
<a href="http://www.youtube.com/watch?v=xdPDn1KUz_A" target="_blank">http://www.youtube.com/watch?v=xdPDn1KUz_A</a>
<a href="http://www.youtube.com/watch?v=_ve4M4UsJQo" target="_blank">http://www.youtube.com/watch?v=_ve4M4UsJQo</a>

and one of my personal favorites...

<a href="http://www.youtube.com/watch?v=NzAQ-jYfEqA" target="_blank">http://www.youtube.com/watch?v=NzAQ-jYfEqA</a>

Feel free to post more Cheesy
7  General Discussion / Miscellaneous Discussion / HUGALOPES! on: 30 December, 2011, 12:34:22
Hello, everyone. A friend of mine is trying to get some attention for his Kickstarter project, and I thought I'd bring it to this wonderful community.

All I can really say is that it would be absolutely wonderful if you guys could spread this around. Other than that I'll let their Kickstarter video speak for itself, but please visit the Kickstarter page as well (link at the bottom).

<a href="http://www.youtube.com/watch?v=f_5WA5lFyp0" target="_blank">http://www.youtube.com/watch?v=f_5WA5lFyp0</a>

Please read and see more here:
http://www.kickstarter.com/projects/1475020745/meet-the-hugalopes-the-future-of-fluffy-fluffy-fun
8  General Discussion / Computer Java Programming Help / QuadDouble precision on: 14 December, 2011, 01:59:47
I'm working on a project in which I'd like to use some very high precision numbers, but I want to avoid using Apfloat as much as possible because of its slow speed.

After looking around I found a DoubleDouble class, which is written to act as (almost) a Quad precision wrapper using two doubles. It has 106 bits of precision instead of the 113 bits that a real Quad data type would have, but that's fine for me.

But I'm still looking for something with even more precision if possible. I'm wondering how I might have a QuadDouble precision class using 4 doubles for precision, instead of only two. Does anyone know if something of this precision already exists, or how I would go about writing a QuadDouble class if it doesn't already?
9  General Discussion / Math and Science / Dividing a map into sections - Help! on: 01 September, 2011, 01:27:04
I'm working on some pathfinding, and I've been trying to find a good way to divide a map up into sections to use as nodes for high-level pathfinding.

Low-level pathing consists of generating the intricate paths required to navigate around obstacles to get to a specified end point, whereas high-level pathing is used to plan out the general route across the map that the low-level path should more or less follow (or at least gravitate toward). High-level pathfinding will ignore small obstacles (like trees or small rocks) and instead focus on finding a general route around any large areas of high ground or large masses of water, or any other major terrain aspects.

Another thing that high-level pathfinding should take into account is any major choke points in the map that could be avoided. This can fairly easily be done by simply adding a higher cost for traveling from one node to another if there's a tight choke point in between the two.

The actual pathfinding is fairly simple to do. The part I'm running into trouble with is creating the high-level nodes in the first place. Basically I've demonstrated what I'm trying to do on the Xel'Naga Caverns map from StarCraft 2 just as an example:


-Red lines show the actual map walls (ehh, so I scribbled them in...close enough).
-Blue lines show where the different sections were divided.
-Green dots show the section center points that will act as the actual high-level nodes.

To demonstrate how these would be used, let's say you want to find a path from the pink dot to the yellow dot. First you generate a high-level path (blue) from the high-level node of the starting section to the high-level node of the ending section. Then you'll generate the actual low-level path (white) using the high-level path as merely a guide for generally where to go.



I'm trying to figure out a way to generate these map sections dynamically, but I'm really not sure how to go about doing it. Any suggestions?

I'm thinking it would work to maybe trace an outline of all the walls and then simplify those outlines to smooth out the chaotic edges and find more of the general shape of the walls, and then use those angles to create the sections, but I'm not sure how to go about simplifying the lines.



EDIT: I found two algorithms that I may be able to use for this: the Ramer-Douglas-Peucker algorithm for simplifying a curve made up of line segments, and the Hertel-Mehlhorn algorithm for approximate convex polygon partitioning.

I can use the first algorithm to simplify the walls of the map, then use the second algorithm to remove inessential edges, leaving me with larger convex areas which I can easily use as the nodes.

The only thing I still have yet to really find is a good polygon triangulation algorithm that doesn't tend to make slivers...I know  Delaunay Triangulation is supposed to avoid long, thin triangles, but I haven't found a very good explanation of the algorithm itself, or any clear implementations of it.
10  General Discussion / Miscellaneous Discussion / Phrase Bulimic on: 31 August, 2011, 18:56:03
Just a poem I found that really captured me. Thought I'd share.

Phrase Bulimic
by Kathleen Burke

Hello, my name is ___, and
I am a phrase bulimic.
A language rearranger.
Do not proofread your thoughts.
Language-
The real life sustainer-
Tastes better coming up than it does going down

Sautee your words in song
Or scramble them with screams
But let them come; feast on them.
They are delicious.

Delight in their delicious, delectable,
Brutal
Fury.
Relish-

Savor
Anger and love.
Taste how one is a spice to mask
The sweet of the other.

Devour verbs
Fight adverbs fervently for their
Lack of commitment
And win.

Write right.
Bite poems savagely and let their juice
Dribble off your chin onto your
Preying hands.

Make a preposition salsa or a predicate salad,
And top it off with fattening adjectives.
Let the salsa, salsa, and the tangy orange tango.
Write it all down.

This smorgasbord is the soup of Society
Is Civilization
And it rages as your soul licks the bowl clean.
Crave soul food.

In this world of pity, anorexia, starvation-
Never go hungry.
11  General Discussion / Computer Projects and Ideas / RTS-style Coordinated Unit Movement on: 31 August, 2011, 02:30:47
I wasn't sure exactly where to put this, but I found some great explanations of concepts and implementation of Coordinated Unit Movement for RTS-style games, though it could be used for any type of game, I suppose. I just thought some people might find this interesting and/or helpful for current or future projects.

Explanation of basic concepts:
http://www.gamasutra.com/view/feature/3313/coordinated_unit_movement.php
Explanation of implementation:
http://www.gamasutra.com/view/feature/3314/implementing_coordinated_movement.php
12  General Discussion / Music Showcase / An old song I wrote... on: 05 August, 2011, 02:34:00
Here's a song I wrote and recorded quite a while ago. It's called "Rickrolled." Guess what it's about.
The quality sucks, the singing is bad, but whatever. It was fun to write. Tongue

http://soupinabox.com/rickrolled.mp3
13  General Discussion / Miscellaneous Discussion / Actors/Actresses on: 03 August, 2011, 07:20:07
Have any favorites?



For actresses, at least, I like Natalie Portman a lot. Not just because she's very attractive, but because she's also a fantastic actress, and she's very intelligent.
Spoiler for image:
Another actress who is also really good and very smart (and looks a lot like Natalie Portman) is Olivia Wilde.
Spoiler for image:
Shout-outs also to Emma Stone...
Spoiler for image:
...and, of course, Emma Watson (who DEFINITELY looked better with long hair).
Spoiler for image:



For actors, I really appreciate Robin Williams for his inhumanly fast comedic brainpower, and his incredible use of characters and character quirks/eccentricity.
Spoiler for image:
I also really like James Franco. He's a very truthful actor, and I really respect that about him.
Spoiler for image:
Another incredibly truthful method-actor that I greatly admire is (or was) Heath Ledger.
Spoiler for image:



These are only a few of my favorites. What are yours?
14  General Discussion / Miscellaneous Discussion / Baryshnikov and Nureyev on: 11 July, 2011, 13:53:52
As you may or may not know, I am quite involved in dance. I recently received a full scholarship to a ballet studio, and I am taking full advantage of that, dancing at least 10 hours a week there, and at least 4 hours a week at another studio as well.

Anyway, being that I am so engaged in ballet lately, I have been watching videos of Mikhail Baryshnikov and Rudolph Nureyev, quite possibly the two best male ballet dancers (ballerinos) in the history of forever.

Rudolph Nureyev dancing Corsaire with Margot Fonteyne (who is also amazing):
<a href="http://www.youtube.com/watch?v=BiIst40or60" target="_blank">http://www.youtube.com/watch?v=BiIst40or60</a>

Mikhail Baryshnikov also dancing Corsaire (though he does only the male variation, a.k.a. the male solo):
<a href="http://www.youtube.com/watch?v=rlPZSAURSb8" target="_blank">http://www.youtube.com/watch?v=rlPZSAURSb8</a>


Obviously on a personal level I am floored by these performances, as was the rest of the classical ballet community. Nobody had ever seen anything like either of these men. It really helps to know what exactly it is that you're looking at, and to have some understanding of how the moves are executed, so being an actual dancer helps, but they're still pretty amazing to watch. I mean, seriously...HOW THE HELL DOES ANYONE EVER JUMP AS HIGH AS NUREYEV?? (see around 3:20 or so) And those incredible turns in both performances...how do you ever keep your balance like that? It's like they're all superhuman!

Oh well...I am aware that many of you may not appreciate this nearly as much as I, but I wish to expand the world's view of dance, especially the concept and acceptance of male dancers. These men were phenomenal, the best there ever was. I hope you can at least appreciate these a little bit.
15  Omnimaga / OmnomIRC and SpyBot45 development / PM's disappear on: 11 July, 2011, 08:31:26
When you get a query in Omnom it displays the message in the current window with (PM) next to the name. It also opens up a new query window in the channel bar...But the query window seems to not log any messages. If switch channels and then switch back, all queries are lost forever in the dark abyss that is deleted data. Cry
Pages: [1] 2 3 4
Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.475 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.