NAND Patch
Moderator: OpenTTD Developers
NAND Patch
This patch adds signal type 5, the NAND pre signal.
A NAND pre signal has the exact ooposite properties of a normal combo signal. In other words, it is red when a normal signal would be green.
Currently, the signal uses the PBS graphics. I do not have enough NewGRF knowledge to chnage this.
I am not sure if I am smashing the semaphore bitflags in rail_map.h. Could a developer check that for me, so I can fix it if I am.
When building a NAND signal, care should be taken to make sure the signals do not form a loop, else OpenTTD will hang changing signal state constantly. You have been warned. I was wondering if the devs have any information on how to avoid this?
Notes:
* Someone check rail_map's bitflags please
* Fix the hang issue (Delay before changing?)
* Custom graphics
Enjoy!
EDIT: Oh yeah, can someone check the code I nicked from PBS applys? Thanks
A NAND pre signal has the exact ooposite properties of a normal combo signal. In other words, it is red when a normal signal would be green.
Currently, the signal uses the PBS graphics. I do not have enough NewGRF knowledge to chnage this.
I am not sure if I am smashing the semaphore bitflags in rail_map.h. Could a developer check that for me, so I can fix it if I am.
When building a NAND signal, care should be taken to make sure the signals do not form a loop, else OpenTTD will hang changing signal state constantly. You have been warned. I was wondering if the devs have any information on how to avoid this?
Notes:
* Someone check rail_map's bitflags please
* Fix the hang issue (Delay before changing?)
* Custom graphics
Enjoy!
EDIT: Oh yeah, can someone check the code I nicked from PBS applys? Thanks
- Attachments
-
- nandv2.diff
- Nand gates, version 2 (Fixes YAPF)
- (6.47 KiB) Downloaded 553 times
You've posted a lot of info about that NAND signal, but you seem to have missed one that interests me: why? What do you gain from being able to build these signals? I wouldn't mind seeing a practical application of them in a screenshot.
A computer scientist is someone who, when told to "Go to Hell," sees the "go to," rather than the destination, as harmful.
They are the basic building blocks of all other gates. From a NAND, you can build an AND, NOR, NOT, OR, etc.
I have a practical application also:
http://res1.humgun.com/ttdnand/statpref.png
This somewhat models a really busy station in the OpenTTD Coop Sandbox, where we want a futher away station to be prefered. With a NAND gate setup as shown, it would be possible.
The trains prefer the extension, which we don't want them to. In the example, the station on the right is the overflow station. While in this example, trains prefer the overflow station, the signaling dictates which way they go anyway.
NANDs can be extremely useful.
EDIT: Made image a link
I have a practical application also:
http://res1.humgun.com/ttdnand/statpref.png
This somewhat models a really busy station in the OpenTTD Coop Sandbox, where we want a futher away station to be prefered. With a NAND gate setup as shown, it would be possible.
The trains prefer the extension, which we don't want them to. In the example, the station on the right is the overflow station. While in this example, trains prefer the overflow station, the signaling dictates which way they go anyway.
NANDs can be extremely useful.
EDIT: Made image a link
Last edited by Owen on 22 Jul 2006 21:16, edited 1 time in total.
Hmmm... to be honest, you completely lost me on that image. I've built my fair share of complicated stuff, but that one surpasses my current ability to figure it out (though it's about bedtime, so that may have something to do with it).
I guess it does have its uses, though I doubt I'll ever use it myself. I am a bit worried that the signal builder is getting a bit overloaded though. If PBS is added back to the mix, you'd be cycling through five signals. If these are added to the game, then the signal gui could do with a make-over as well to resolve that issue.
P.S. That image is rather wide to be placed inline in the post. You might want to either crop it or put it in an attachment.
P.P.S. Transistor Tycoon anyone?
I guess it does have its uses, though I doubt I'll ever use it myself. I am a bit worried that the signal builder is getting a bit overloaded though. If PBS is added back to the mix, you'd be cycling through five signals. If these are added to the game, then the signal gui could do with a make-over as well to resolve that issue.
P.S. That image is rather wide to be placed inline in the post. You might want to either crop it or put it in an attachment.
P.P.S. Transistor Tycoon anyone?
A computer scientist is someone who, when told to "Go to Hell," sees the "go to," rather than the destination, as harmful.
some pics, by popular demand
EIDT: updated the diff to avoid game hangs on NAND loops
EIDT: updated the diff to avoid game hangs on NAND loops
- Attachments
-
- the_flip_flop_RS.PNG
- the wonderful flip-flop R/S
- (333.25 KiB) Downloaded 1195 times
-
- some_gates.PNG
- some logic gates
- (292.73 KiB) Downloaded 1445 times
-
- nand_miniIN.diff
- the diff for the latest miniIN
- (6.47 KiB) Downloaded 703 times
Last edited by Wolf01 on 22 Jul 2006 22:24, edited 1 time in total.
Update, to remove the hang issue. A presignal change can no longer affect more than 10 blocks however. I hope that this becomes configurable
- Attachments
-
- nandv3.diff
- Version 3
- (7.36 KiB) Downloaded 428 times
Ensuring all tracks are free:
EDIT: 99% Perfect balancer (Trains will go to A, B, A, B 99% of the time. The 1% being when a train sits on a flipper)
EDIT: 99% Perfect balancer (Trains will go to A, B, A, B 99% of the time. The 1% being when a train sits on a flipper)
- Attachments
-
- alltracks.png (47.41 KiB) Viewed 16262 times
-
- NAND Balancer
- nandbalancer.png (42.84 KiB) Viewed 16259 times
Last edited by Owen on 22 Jul 2006 23:56, edited 1 time in total.
If I find my old book of microelectronics, maybe 'll try an small binary adder with carry bit
Good old times when I attend the campus...
Good old times when I attend the campus...
Sidewinder
Italian Town names patch for OTTD (R5266) now in trunk since 0.4.8
For typo, errors or bug on OTTD italian translation, please PM me.
unofficial italian TTD/OpenTTD forum: http://wolf01.game-host.org/forum/index.php
Italian Town names patch for OTTD (R5266) now in trunk since 0.4.8
For typo, errors or bug on OTTD italian translation, please PM me.
unofficial italian TTD/OpenTTD forum: http://wolf01.game-host.org/forum/index.php
-
- Transport Coordinator
- Posts: 340
- Joined: 06 Feb 2006 23:58
I don't know if you fixed it already, but you need to change the Set/GetSignalVariant functions to make Semaphores work again.
They can be found in rail_cmd.c.
Just modify them to get/set bit 3 instead of 2.
This gave me some serious headache while trying to use them with my copy&paste patch
Code: Select all
static inline SignalVariant GetSignalVariant(TileIndex t)
{
return (SignalVariant)GB(_m[t].m4, 3, 1);
}
static inline void SetSignalVariant(TileIndex t, SignalVariant v)
{
SB(_m[t].m4, 3, 1, v);
}
Just modify them to get/set bit 3 instead of 2.
This gave me some serious headache while trying to use them with my copy&paste patch
Version 4, incorporating Frostregen's fixes although they were developed independently. I also bumped the cascade limit to 20 since 10 seemed limiting.
- Attachments
-
- nandv4.diff
- Version 4, for the current trunk revision r5596
- (7.48 KiB) Downloaded 446 times
NAND Path version 5
Changes:
* Only counts NAND signals now
* When an overflow occurs, displays an error message. While it doesn't tell you the location, chances are this will only occur while building anyway[/b]
To apply, gunzip the diff and apply. Under Linux, do the following:
Edit: Added MiniIN patch
Changes:
* Only counts NAND signals now
* When an overflow occurs, displays an error message. While it doesn't tell you the location, chances are this will only occur while building anyway[/b]
To apply, gunzip the diff and apply. Under Linux, do the following:
Code: Select all
cat nandv5.diff.gz | gunzip | patch
- Attachments
-
- nandv5.diff.gz
- NandV5
- (2.78 KiB) Downloaded 448 times
-
- nandv5-min.diff
- MiniIN patch
- (8.51 KiB) Downloaded 444 times
miniIN diff with configurable nand cascading in configure patches
- Attachments
-
- nand_miniIN_configurable.diff
- (10.61 KiB) Downloaded 448 times
Some code-wise tips/trucks you might want to alter:
- Follow the OpenTTD Coding Guidelines
-> if() is wrong, it should have a space between if and ()
-> Don't printf stuff, use DEBUG()
- The define in variables.h might not be the best place. Also, capitals for defines are more common
I am sure there are some more things (nobody is perfect ), but that is what I noticed after a quick look I have to say I like it very much, it is nice to have a full logic-set of signals
Ps: post it at http://bugs.openttd.org, so devs will notice it
- Follow the OpenTTD Coding Guidelines
-> if() is wrong, it should have a space between if and ()
-> Don't printf stuff, use DEBUG()
- The define in variables.h might not be the best place. Also, capitals for defines are more common
I am sure there are some more things (nobody is perfect ), but that is what I noticed after a quick look I have to say I like it very much, it is nice to have a full logic-set of signals
Ps: post it at http://bugs.openttd.org, so devs will notice it
Who is online
Users browsing this forum: No registered users and 15 guests