forked from wiremod/wire
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally a proper SVN Layout, see people this is what happens when you…
… use a system intended for developers NOT end users.
- Loading branch information
FaronFox
committed
Oct 7, 2009
0 parents
commit d8f0b9c
Showing
873 changed files
with
84,464 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//Usage (in & out): | ||
//Port0 - Air amount (output in percent) | ||
//Port1 - Coolant amount (output in percent) | ||
//Port2 - Energy amount (output in percent) | ||
//Port3 - Pressure (output in KPA) | ||
//Port4 - Temperature (output in Celsiums) | ||
//Change these values | ||
define MAXAIR,12000; | ||
define MAXCOOLANT,12000; | ||
define MAXENERGY,12000; | ||
mainloop: | ||
//Air% = (Air / MaxAmount) * 100 | ||
mov eax,port0; | ||
div eax,MAXAIR; //MAXIMUM AMOUNT OF AIR | ||
mul eax,100; | ||
int eax; inc eax; | ||
mov port0,eax; | ||
|
||
//Coolant% = (Coolant / MaxAmount) * 100 | ||
mov eax,port1; | ||
div eax,MAXCOOLANT; //MAXIMUM AMOUNT OF COOLANT | ||
mul eax,100; | ||
int eax; inc eax; | ||
mov port1,eax; | ||
|
||
//Energy% = (Energy / MaxAmount) * 100 | ||
mov eax,port2; | ||
div eax,MAXENERGY; //MAXIMUM AMOUNT OF ENERGY | ||
mul eax,100; | ||
int eax; inc eax; | ||
mov port2,eax; | ||
|
||
//Pressure(KPA) = (Pressure * 101325) / 1000 | ||
mov eax,port3; | ||
mul eax,101325; | ||
div eax,1000; | ||
mov port3,eax; | ||
|
||
//Temperature C* = K - 273 | ||
mov eax,port4; | ||
sub eax,273; | ||
mov port4,eax; | ||
|
||
jmp mainloop; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//Bouncing ball for digital screen (Hi-speed) | ||
DATA; | ||
alloc bx; | ||
alloc by; | ||
alloc vx; | ||
alloc vy; | ||
CODE; | ||
mov #bx,15; | ||
mov #by,15; | ||
//Experiment with velocity: | ||
mov #vx,1; | ||
mov #vy,1; | ||
call bScreenErase; | ||
//Main loop | ||
mainloop: | ||
//Erase old ball | ||
mov ecx,0; | ||
call bPaintBall; | ||
|
||
//Move ball using velocity | ||
add #bx,#vx; | ||
add #by,#vy; | ||
//Bounce against X walls | ||
cmp #bx,0; | ||
cle bReverseX; | ||
cmp #bx,31; | ||
cge bReverseX; | ||
//Bounce against Y walls | ||
cmp #by,0; | ||
cle bReverseY; | ||
cmp #by,31; | ||
cge bReverseY; | ||
|
||
//Paint new ball | ||
mov ecx,255; | ||
call bPaintBall; | ||
jmp mainloop; | ||
//---------------------------------------------------- | ||
// Calculates ball VRAM address | ||
// Result in EAX | ||
//---------------------------------------------------- | ||
bCalcAddress: | ||
mov eax,#by; | ||
mul eax,32; | ||
add eax,#bx; | ||
add eax,65536; //VRAM Offset | ||
ret | ||
//---------------------------------------------------- | ||
// Erases the screen | ||
//---------------------------------------------------- | ||
bScreenErase: | ||
mov edi,65536; | ||
scrEraseLoop: | ||
mov #edi,0; | ||
inc edi; | ||
cmp edi,66559; | ||
jle scrEraseLoop; | ||
ret | ||
//---------------------------------------------------- | ||
// Reverse ball X (Short, but easy) | ||
//---------------------------------------------------- | ||
bReverseX: | ||
neg #vx; | ||
ret | ||
//---------------------------------------------------- | ||
// Reverse ball Y (Short, but easy) | ||
//---------------------------------------------------- | ||
bReverseY: | ||
neg #vy; | ||
ret | ||
//---------------------------------------------------- | ||
// Paint ball | ||
// Paints ball in color stored in ECX | ||
//---------------------------------------------------- | ||
bPaintBall: | ||
call bCalcAddress; | ||
mov #eax,ecx; | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//Digital camera using ports | ||
//Outputs: | ||
//PORT0 - Ranger X | ||
//PORT1 - Ranger Y | ||
//PORT5 - Digital screen X | ||
//PORT6 - Digital screen Y | ||
//PORT7 - Digital screen G (gray) | ||
//Inputs: | ||
//PORT0 - Ranger data | ||
define MAXRANGE,1024; //Ranger range | ||
mov eax,0; //EAX = 0 | ||
mov ebx,0; //EBX = 0 | ||
loopx: //Loop X value | ||
mov ebx,0; //EBX = 0 | ||
loopy: //Loop Y value | ||
mov port5,eax; //Port5 = EAX (X) | ||
mov ecx,port0; //ECX = PORT0 | ||
div ecx,MAXRANGE; //ECX = ECX / MAXRANGE | ||
mul ecx,255; //ECX = ECX * 255 | ||
neg ecx; //ECX = -ECX | ||
add ecx,255; //ECX = ECX + 255 | ||
mov port7,ecx; //PORT7 = ECX (ECX = 255-(PORT0 / MAXRANGE)*255) | ||
mov port6,ebx; //PORT6 = EBX (Y) | ||
mov ecx,eax; //ECX = EAX | ||
div ecx,16; //ECX = ECX / 16 - 1 | ||
sub ecx,1; | ||
mov edx,ebx; //ECX = EBX | ||
div edx,16; //EDX = EDX / 16 - 1 | ||
sub edx,1; | ||
mov port0,ecx; //Ranger X = ECX | ||
mov port1,edx; //Ranger Y = EDX | ||
inc ebx; //Increase Y | ||
cmp ebx,32; //Compare to 32 | ||
jl loopy; //If less then loop | ||
inc eax; //Increase X | ||
cmp eax,32; //Compare to 32 | ||
jl loopx; //If less then loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//Working multifloor elevator | ||
//Ports: | ||
//IN: | ||
//PORT0 - Button pressed, reversed | ||
//PORT1 - Elevator speed | ||
//OUT: | ||
//PORT0 - Motor | ||
//PORT5 - Current floor number | ||
//PORT6 - Moving LED, and elevator door status | ||
//PORT7 - Floor door open status | ||
|
||
//////// Data segment | ||
DATA; //Allocate data segment (Everything after it | ||
// and before CODE; is allocated in data segment) | ||
alloc floor; //Create variable named "floor" and set it to 0 | ||
alloc z; //Create variable named "z" and set it to 0 | ||
alloc destz; //Create variable named "destz" and set it to 0 | ||
//////// Code segment & initialization routine | ||
CODE; //Initialize code segment (Everything below is code) | ||
mov #z,0; //Store 0 into variable named Z (# means we write to memory) | ||
mov port0,#z; //Store variable Z into port0 (# means we read from memory) | ||
mov port5,1; //Store 1 into port 5 (we are on floor 1) | ||
mov port7,1; //Store 1 into port 7 (doors are open) | ||
mov #floor,1; //Store 1 into floor counter | ||
//////// Read for button presses | ||
btnloop: //Create label named "btnloop" | ||
mov eax,port0; //Store port0 into EAX general-purpose register | ||
cmp eax,0; //Compare EAX with 0 | ||
je btnloop; //If EAX is greater than 0 then jump to label "btnloop" | ||
//////// Choose movement direction | ||
mov port6,1; //EAX > 0 means some buttons was pressed. Store 1 into moving led port | ||
mov port7,0; //Store 0 into port 7 (close doors) | ||
mul eax,256; //Multiply pressed button number by 256 | ||
sub eax,256; //Subtract 256 from pressed button number | ||
mov #destz,eax; //Target elevator height - (ButtonNumber - 1) * 256 | ||
cmp #destz,#z; //Compare value in "destz" with value in "z" | ||
je dontmove; //If its equal, then dont move. Jump over movement | ||
jl movedown; //If its not equal, and less then jump to move down code | ||
//////// Move up | ||
moveup: //If its greater than jump to move up code | ||
add #z,port1; //Add elevator speed to Z value | ||
mov port0,#z; //Set elevator height to the new Z value | ||
call calcfloor; //Calculate & show floor number | ||
cmp #destz,#z; //Compare, are we done moving yet | ||
jg moveup; //We are moving up, and destanation > current Z. Continue moving | ||
jmp dontmove; //We are on the floor. Jump over move down code | ||
//////// Move down | ||
movedown: //Move down code | ||
sub #z,port1; //Subtract speed from Z value | ||
mov port0,#z; //Set the new elevator height | ||
call calcfloor; //Calculate & show floor number | ||
cmp #destz,#z; //Compare destanation Z with our Z | ||
jl movedown; //If its under us then continue moving | ||
//////// Finished moving | ||
dontmove: //We finished moving/already at floor | ||
mov #z,#destz; //Store destz into z to prevent mistakes with floor height | ||
mov port7,1; //Open doors on floor (previously calculated with calcfloor | ||
mov port6,0; //Turn off moving LED and open elevator doors | ||
jmp btnloop; //Jump and wait for keypress again | ||
|
||
//////// public CalcFloor() | ||
calcfloor: //FloorNumber = CalcFloor() | ||
mov eax,#z; //Store current height into EAX | ||
add eax,256; //Floor number = math.Round((z+256) / 256) | ||
div eax,256; //Divide... | ||
rnd eax; //Round up value in EAX, and store it back into EAX | ||
mov #floor,eax; //Store floor number | ||
mov port5,eax; //Display the floor number | ||
ret //Return from function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//Wired Hello World! | ||
//Connect CPU membus input to console screen | ||
//Connect CPUs CLK input to button (toggle) | ||
//Notice how you can store your | ||
//subroutines/calls in DATA area | ||
DATA; | ||
message: | ||
db 'Hello World!',0; | ||
WriteString: //ESI - String pointer, EDX - Param | ||
mov eax,65536; | ||
AWriteLoop: | ||
cmp #esi,0; //Terminate on char 0 | ||
je AEnd; | ||
mov #eax,#esi; //Output char | ||
inc eax; | ||
mov #eax,edx; //Output char param | ||
inc eax; | ||
inc esi; | ||
jmp AWriteLoop; | ||
AEnd: | ||
ret //Return from call | ||
|
||
CODE; | ||
mov esi,message; | ||
mov edx,000999; //White foreground on black background | ||
call WriteString; | ||
|
||
//More about colors: | ||
//Lower 3 digits are foreground, | ||
//and higher 3 digits are background | ||
//Each of 3 digits shows amount of | ||
//RED, GREEN, and BLUE (in order) | ||
//Each color has 10 shades - from 0 to 9 | ||
// | ||
//For example, 999044 will be dark yellow (044) on | ||
//a white background (999) | ||
// | ||
//Experiment with colors! | ||
// | ||
//Also, the 7th digit (if its not equal to 0) will | ||
//cause the character to blink by changing foreground and | ||
//background places (actual data in memory wont change) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Screen test using ports | ||
// Spawn 1 cpu, 1 digital screen, and 1 input. | ||
// Attach CPUs clock input to keypad input. | ||
// Attach digital screens clock input to keypad input. | ||
// Attach digital screens pixelg input to CPUs port2 output. | ||
// Attach digital screens pixelx input to CPUs port0 output. | ||
// Attach digital screens pixely input to CPUs port1 output. | ||
mov eax,0; // EAX = 0 | ||
loopx: // Loop #1 (X-axis) | ||
mov ebx,0; // EBX = 0 | ||
loopy: // Loop #2 (Y-axis) | ||
mov port0,eax; // Port[0] = EAX | ||
mov port1,ebx; // Port[1] = EBX | ||
mov edx,eax; // EDX = EAX | ||
mul edx,ebx; // EDX = EDX*EBX (aka EDX = EAX*EBX) | ||
mov port2,edx; // Port[2] = EDX (aka Port[2] = EAX*EBX) | ||
inc ebx; // EBX = EBX + 1 | ||
cmp ebx,32; // Compare EBX and 32 | ||
jl loopy; // Jump if less than 32 | ||
inc eax; // EAX = EAX + 1 | ||
cmp eax,32; // Compare EAX and 32 | ||
jl loopx; // Jump if less than 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Screen test using hi-speed link | ||
// Spawn 1 cpu, 1 digital screen, and 1 button (toggle). | ||
// Attach CPUs clock input to button. | ||
// Attach digital screens clock input to button. | ||
// Attach CPU's MemBus input to digital screen | ||
mov eax,0; // EAX = 0 | ||
loopx: // Loop #1 (X-axis) | ||
mov ebx,0; // EBX = 0 | ||
loopy: // Loop #2 (Y-axis) | ||
mov edi,ebx; // EDI - Screen Byte Number | ||
mul edi,32; // EDI = Y * 32 + X | ||
add edi,eax; // EDI = EDI + 65536 (Because screen is linked | ||
add edi,65536; // to top of CPU ram, i.e. 65536 and so on) | ||
mov edx,eax; // EDX = EAX | ||
mul edx,ebx; // EDX = EDX*EBX (aka EDX = EAX*EBX) | ||
mov #edi,edx; // Screen[EDI] = EDX (Screen's byte EDI) | ||
inc ebx; // EBX = EBX + 1 | ||
cmp ebx,32; // Compare EBX and 32 | ||
jl loopy; // Jump if less than 32 | ||
inc eax; // EAX = EAX + 1 | ||
cmp eax,32; // Compare EAX and 32 | ||
jl loopx; // Jump if less than 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//SpeedTest - Outputs average number of | ||
//CPU clocks passed | ||
//Attach data port to IOBus of CPU | ||
mov eax,1; | ||
infloop: | ||
add eax,3; //3 cycles for the loop | ||
mov port0,eax; | ||
jmp infloop; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@name Hello World | ||
@inputs A B | ||
@outputs Add Sub Mul Div | ||
@outputs GreaterThan Highest Lowest | ||
@outputs Vector:vector | ||
@persist D | ||
@trigger all | ||
|
||
Add = A + B | ||
Sub = A - B | ||
Mul = A * B | ||
Div = A / B | ||
|
||
GreaterThan = A > B | ||
|
||
if(A > B) { | ||
Highest = A, Lowest = B | ||
} else { | ||
Highest = B, Lowest = A | ||
} | ||
|
||
Vector = vec(A, B, 0) | ||
Vector = Vector + vec(0, 0, A + B) | ||
Vector = Vector:normalized() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
N@Advanced Smoother | ||
I@Target Speed Acceleration | ||
O@Value Active | ||
# Activate when target has been set | ||
~Target -> Active = 1; | ||
|
||
# Main computation loop | ||
first() | clk() -> | ||
# Precomputation of inputs | ||
!Acceleration -> Acceleration = Speed * 50 * 2; | ||
AccLength = Speed^2 / Acceleration / 2 | ||
AccRate = min(Speed, Acceleration / 50) | ||
# Precomputation of variables | ||
Distance = Target - Value | ||
Direction = Distance >= 0 ? 1 : -1 | ||
# Calculate ideal speed modifier | ||
IdealRate = Speed * Direction | ||
abs(Distance) <= AccLength -> | ||
IdealRate *= sqrt(abs(Distance - Rate / 50) / AccLength); | ||
# Calculate final speed for iteration | ||
Rate += clamp(IdealRate - Rate, -Acceleration / 50, Acceleration / 50) | ||
Value += Rate / 50 | ||
# Check if value has reached target | ||
Active = abs(Rate) > AccRate | ||
| abs(Distance) > AccRate / 50 | ||
!Active -> Rate = 0, Value = Target;; | ||
|
||
# Schedule the main loop if active | ||
Active -> interval(20); |
Oops, something went wrong.