diff options
| author | cheapie <cheapiephp@gmail.com> | 2026-11-08 10:59:21 -0600 |
|---|---|---|
| committer | cheapie <cheapiephp@gmail.com> | 2026-11-08 10:59:21 -0600 |
| commit | 56d1b0013d38682aac6625ae7f9edfeb15f8c710 (patch) | |
| tree | 5893a24c098c75cffa35018cd093b44f62dc9b46 /assembly/rrxing2 | |
| parent | 6606efb7a449f2ff2bc5dd49b20b12d9138861e9 (diff) | |
| download | rvcontroller-56d1b0013d38682aac6625ae7f9edfeb15f8c710.tar rvcontroller-56d1b0013d38682aac6625ae7f9edfeb15f8c710.tar.gz rvcontroller-56d1b0013d38682aac6625ae7f9edfeb15f8c710.tar.bz2 rvcontroller-56d1b0013d38682aac6625ae7f9edfeb15f8c710.tar.xz rvcontroller-56d1b0013d38682aac6625ae7f9edfeb15f8c710.zip | |
Allow reactivating crossing during deactivation sequence
Diffstat (limited to 'assembly/rrxing2')
| -rw-r--r-- | assembly/rrxing2/rrxing2.S | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/assembly/rrxing2/rrxing2.S b/assembly/rrxing2/rrxing2.S index f9308f8..ba8dac9 100644 --- a/assembly/rrxing2/rrxing2.S +++ b/assembly/rrxing2/rrxing2.S @@ -110,9 +110,11 @@ addi t1,t1,1 # And add 1 to get to the first non-idle state la t0,currstate sb t1,0(t0) # Update state in RAM to the first state in the current country la t0,states -sh2add t0,t1,t0 # Calculate the proper offset in the list of pointers (state number * 4 + base address) -lw t0,0(t0) # Load the pointer -jalr ra,t0,0 # And call that function +addi t2,t1,1 # Landing pad label is state number + 1 (to avoid having any of them be 0) +slli t2,t2,12 +sh2add t1,t1,t0 # Calculate the proper offset in the list of pointers (state number * 4 + base address) +lw t1,0(t1) # Load the pointer +jalr ra,t1,0 # And call that function 2: la t0,currstate lb s0,0(t0) # Re-read current state from RAM @@ -124,7 +126,27 @@ li t1,35 beq s0,t1,1f # State 35 (US state 3): reset timer j 2f # None of the above, skip over the reset 1: set_timer_to extensiontime -2: li a7,133 +2: + +la t0,restartvalid +lb t1,0(t0) +beqz t1,1f # Check if the current state is something that can be restarted from +sb x0,0(t0) +la t0,currstate +lb t1,0(t0) +addi t1,t1,1 # State may be negative at the moment if we were on the last state +andi t1,t1,0xfffffff0 # Find state 0 for the current country +addi t1,t1,1 # Increment to state 1 +sb t1,0(t0) # Write the new state +la t0,states +addi t2,t1,1 # Landing pad label is state number + 1 (to avoid having any of them be 0) +slli t2,t2,12 +sh2add t0,t1,t0 # Calculate the proper offset in the list of pointers (state number * 4 + base address) +lw t0,0(t0) # Load the pointer +jalr ra,t0,0 # And call that function +1: + +li a7,133 ecall # Check if there are more messages to process bnez a0,handler_digilines j handler_epilogue @@ -215,6 +237,8 @@ digiline_send lightchannel,lightoffmsg digiline_send gatechannel,gateupmsg digiline_send bellchannel,belloffmsg digiline_send signalchannel,lightoffmsg +la t0,restartvalid +sb x0,0(t0) ret .align 2 @@ -258,6 +282,9 @@ destate6: lpad 7 digiline_send gatechannel,gateupmsg set_timeri 2 +la t0,restartvalid +li t1,1 +sb t1,0(t0) la t0,currstate li t1,-1 sb t1,0(t0) # Next state should be 0 @@ -271,6 +298,8 @@ digiline_send lightchannel,lightoffmsg digiline_send gatechannel,gateupmsg digiline_send bellchannel,belloffmsg digiline_send signalchannel,lightflashredmsg +la t0,restartvalid +sb x0,0(t0) ret .align 2 @@ -314,6 +343,9 @@ ukstate6: lpad 23 digiline_send signalchannel,lightflashredmsg digiline_send bellchannel,belloffmsg +la t0,restartvalid +li t1,1 +sb t1,0(t0) set_timeri 1 ret @@ -335,6 +367,8 @@ digiline_send lightchannel,lightoffmsg digiline_send gatechannel,gateupmsg digiline_send bellchannel,belloffmsg digiline_send signalchannel,lightoffmsg +la t0,restartvalid +sb x0,0(t0) ret .align 2 @@ -367,6 +401,9 @@ lpad 37 digiline_send signalchannel,lightoffmsg digiline_send gatechannel,gateupmsg set_timeri 3 +la t0,restartvalid +li t1,1 +sb t1,0(t0) la t0,currstate li t1,31 sb t1,0(t0) # Next state should be 32 (US state 0) @@ -379,6 +416,7 @@ gatedroptime: .byte 3 activetime: .byte 15 extensiontime: .byte 25 traincounter: .word 0 +restartvalid: .byte 0 uiunimplementedtrap: .asciz "\nUnimplemented trap!\nmcause: " uinmi: .asciz "\nUnexpected NMI!\nmncause: " |
