;redcode
;name TheNightTrainV2
;author Skybuck Flying
;strategy Concept Code for a moving warrior (Runs over enemy warriors like a
fricking freight train at night !

erases it's trail).
;date 9 december 2007
;version 2
;history version 1 and 2 created on 9 december 2007
; Demonstrates how to move a warrior forward.
; Also demonstrates how to use a boot program for easy execution order and
stuff like that.
;
; This code will probably be used to construct the moving death star ! OH
YEAH ! =D
; which will probably be a very powerfull warrior in the future ! =D
;
; Version 1 left a trail behind and was trackable by scanners. (Version 1
worked without a boot program)
; Version 2 includes a trail erasor, a boot program was used to makes it
easier to get the correct thread order.
; The trail is now erased which should make us harder to track !
TheStationBegin
TheStationThreadCreatorBegin
; initializes the reset variable with correct values to use for the loop
reset.
TheNightTrainDetermineCoalType mov.f TheNightTrainSourceDest,
TheNightTrainCoal
; The current length of the night train example is 10
; for each cell of the night train a thread is needed to copy it.
; so that means at least 10 threads.
; however one extra thread is needed to reset the engine at the end of
every copy
; and version 2 of the night train has a new feature which is called the
trail erasor
; to erase the trail that is left behind to prevent scanners from tracking
the train
; this requires another thread.
; so the total number of threads to spawn for this example is 10 + 1 for
reset + 1 for erase = 12
; the main thread already counts for 1
; so we need to create 11 additional threads, which is binary 1011
spl 1
mov -1, 0
spl 1
spl 1
TheStationThreadCreatorEnd
TheStationThreadExecutionOrderBootProgramBegin
jmp >ThreadCounter
ThreadCounter dat $0, $1
Thread1JumpTo jmp TheNightTrainEngine
Thread2JumpTo jmp TheNightTrainEngine
Thread3JumpTo jmp TheNightTrainEngine
Thread4JumpTo jmp TheNightTrainEngine
Thread5JumpTo jmp TheNightTrainEngine
Thread6JumpTo jmp TheNightTrainEngine
Thread7JumpTo jmp TheNightTrainEngine
Thread8JumpTo jmp TheNightTrainEngine
Thread9JumpTo jmp TheNightTrainEngine
Thread10JumpTo jmp TheNightTrainEngine
Thread11JumpTo jmp TheNightTrainInjectCoal + 1 ; the instructions will be
moved ahead by one, so compensate for it
Thread12JumpTo jmp TheNightTrainEraseTrail + 1
TheStationThreadExecutionOrderBootProgramEnd
TheStationEnd
TheNightTrainBegin
; not used TheNightTrainLength equ TheNightTrainEnd - TheNightTrainBegin
TheNightTrainLocomotiveBegin
TheNightTrainSourceDest dat #TheNightTrainEnd, #TheNightTrainEnd + 1
TheNightTrainEngine mov {TheNightTrainSourceDest,
<TheNightTrainSourceDest
TheNightTrainLocomotiveEnd
TheNightTrainPayloadBegin
; can be anything, extra threads could be spawned here to do extra stuff
like bomb stuff.
nop 1
nop 2
nop 3
nop 4
TheNightTrainPayloadEnd
TheNightTrainCoalBegin
TheNightTrainInjectCoal mov.f TheNightTrainCoal, TheNightTrainSourceDest
TheNightTrainEraseTrail mov TheNightTrainErasor,
TheNightTrainLocomotiveBegin - 1 ; compensate for moved instructions.
TheNightTrainCoal dat #0, #0
TheNightTrainErasor dat $0, $0
; data members must be behind otherwise movers will fail because move
instruction will be moved by then...
; move instruction must be the last one to be moved !

except for the
source/dest
; data needs to be copied as well.
TheNightTrainCoalEnd
TheNightTrainEnd
dat $0, $0 ; included to make pmars compilers happy, wincore doesn't really
need it,
; however this changes some offsets, so code has been altered to
compensate for it
; so this empty/useless instruction is now needed for correct functioning
! so don't remove it !
