From 799584fe24f68372c9c39f75006ae518243e3013 Mon Sep 17 00:00:00 2001 From: cheapie Date: Fri, 6 Nov 2026 09:36:50 -0600 Subject: More rrxing2 work --- assembly/rrxing2/LICENSE | 22 +++ assembly/rrxing2/rrxing2.S | 6 + assembly/rrxing2/ui.S | 392 ++++++++++++++++++++++++++++++++++++++++++++- assembly/rrxing2/util.S | 24 +++ 4 files changed, 440 insertions(+), 4 deletions(-) create mode 100644 assembly/rrxing2/LICENSE diff --git a/assembly/rrxing2/LICENSE b/assembly/rrxing2/LICENSE new file mode 100644 index 0000000..b3dbff0 --- /dev/null +++ b/assembly/rrxing2/LICENSE @@ -0,0 +1,22 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/assembly/rrxing2/rrxing2.S b/assembly/rrxing2/rrxing2.S index 4501948..f2ab068 100644 --- a/assembly/rrxing2/rrxing2.S +++ b/assembly/rrxing2/rrxing2.S @@ -1,3 +1,8 @@ +# Railroad Crossing 2 for RVController - Main File +# A product of Scheiße & Broken Signalling Systems, a Cheapie Systems company +# This is free and unencumbered software released into the public domain. +# See http://unlicense.org/ for more information + j _start .include "util.S" @@ -365,6 +370,7 @@ lightredmsg: .asciz "RED" lightyellowmsg: .asciz "YELLOW" lightgreenmsg: .asciz "GREEN" lightflashredmsg: .asciz "FLASHRED" +lightflashyellowmsg: .asciz "FLASHYELLOW" belloffmsg: .asciz "off" bellonmsg: .asciz "on" gateupmsg: .asciz "up" diff --git a/assembly/rrxing2/ui.S b/assembly/rrxing2/ui.S index ba1611a..d6c8cd0 100644 --- a/assembly/rrxing2/ui.S +++ b/assembly/rrxing2/ui.S @@ -1,3 +1,8 @@ +# Railroad Crossing 2 for RVController - User Interface +# A product of Scheiße & Broken Signalling Systems, a Cheapie Systems company +# This is free and unencumbered software released into the public domain. +# See http://unlicense.org/ for more information + # UI Pages # Page 0: Idle/Active Screen # Page 1: Main Menu @@ -8,6 +13,16 @@ # Page 6: Extension Time Adjustment # Page 7: Invalid Input Message for Time Adjustments # Page 8: Diagnostics Menu +# Page 9: Output Test Menu +# Page 10: Road Signal Test +# Page 11: Rail Signal Test +# Page 12: Bell Test +# Page 13: Gate Test +# Page 14: Statistics +# Page 15: About 1 +# Page 16: About 2 +# Page 17: About 3 +# Page 18: About 4 mainloop: la t0,uipage @@ -128,12 +143,17 @@ bne a0,t0,1f la t1,uipage li t2,3 sb t2,0(t1) # User entered '2', go to timing adjustment (page 3) -1:li t0,'3' +1: li t0,'3' bne a0,t0,1f la t1,uipage li t2,8 sb t2,0(t1) # User entered '3', go to diagnostics (page 8) -1:li t0,'0' +1: li t0,'4' +bne a0,t0,1f +la t1,uipage +li t2,15 +sb t2,0(t1) # User entered '4', go to about 1 (page 15) +1: li t0,'0' bne a0,t0,1f la t1,uipage sb x0,0(t1) # User entered '0', go to idle screen (page 0) @@ -451,6 +471,357 @@ uihandlediagnostics: lpad 9 li a7,132 ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la t1,uipage +li t0,9 +sb t0,0(t1) # User entered '1', go to output test (page 9) +1: li t0,'2' +bne a0,t0,1f +la t1,uipage +li t0,14 +sb t0,0(t1) # User entered '1', go to statistics (page 14) +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,1 +sb t0,0(t1) # User entered '0', go to main menu (page 1) +1: ret + +.align 2 +uidrawoutputtest: +lpad 10 +la a0,uioutputtest +li a7,4 +ecall +ret + +.align 2 +uihandleoutputtest: +lpad 10 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la t1,uipage +li t0,10 +sb t0,0(t1) # User entered '1', go to light test (page 10) +1: li t0,'2' +bne a0,t0,1f +la t1,uipage +li t0,11 +sb t0,0(t1) # User entered '2', go to signal test (page 11) +1: li t0,'3' +bne a0,t0,1f +la t1,uipage +li t0,12 +sb t0,0(t1) # User entered '3', go to bell test (page 12) +1: li t0,'4' +bne a0,t0,1f +la t1,uipage +li t0,13 +sb t0,0(t1) # User entered '4', go to gate test (page 13) +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,8 +sb t0,0(t1) # User entered '0', go to diagnostics (page 8) +1: ret + +.align 2 +uidrawlighttest: +lpad 11 +la a0,uilighttest +li a7,4 +ecall +ret + +.align 2 +uihandlelighttest: +lpad 11 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la a0,lightchannel +la a1,lightoffmsg +li a7,129 +ecall # User entered '1', command light to off +1: li t0,'2' +bne a0,t0,1f +la a0,lightchannel +la a1,lightredmsg +li a7,129 +ecall # User entered '2', command light to red +1: li t0,'3' +bne a0,t0,1f +la a0,lightchannel +la a1,lightyellowmsg +li a7,129 +ecall # User entered '3', command light to yellow +1: li t0,'4' +bne a0,t0,1f +la a0,lightchannel +la a1,lightgreenmsg +li a7,129 +ecall # User entered '4', command light to green +1: li t0,'5' +bne a0,t0,1f +la a0,lightchannel +la a1,lightflashredmsg +li a7,129 +ecall # User entered '5', command light to flashing red +1: li t0,'6' +bne a0,t0,1f +la a0,lightchannel +la a1,lightflashyellowmsg +li a7,129 +ecall # User entered '6', command light to flashing yellow +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,9 +sb t0,0(t1) # User entered '0', go to output test (page 9) +1: ret + +.align 2 +uidrawsignaltest: +lpad 12 +la a0,uisignaltest +li a7,4 +ecall +ret + +.align 2 +uihandlesignaltest: +lpad 12 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la a0,signalchannel +la a1,lightoffmsg +li a7,129 +ecall # User entered '1', command signal to off +1: li t0,'2' +bne a0,t0,1f +la a0,signalchannel +la a1,lightredmsg +li a7,129 +ecall # User entered '2', command signal to red +1: li t0,'3' +bne a0,t0,1f +la a0,signalchannel +la a1,lightyellowmsg +li a7,129 +ecall # User entered '3', command signal to yellow +1: li t0,'4' +bne a0,t0,1f +la a0,signalchannel +la a1,lightgreenmsg +li a7,129 +ecall # User entered '4', command signal to green +1: li t0,'5' +bne a0,t0,1f +la a0,signalchannel +la a1,lightflashredmsg +li a7,129 +ecall # User entered '5', command signal to flashing red +1: li t0,'6' +bne a0,t0,1f +la a0,signalchannel +la a1,lightflashyellowmsg +li a7,129 +ecall # User entered '6', command signal to flashing yellow +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,9 +sb t0,0(t1) # User entered '0', go to output test (page 9) +1: ret + +.align 2 +uidrawbelltest: +lpad 13 +la a0,uibelltest +li a7,4 +ecall +ret + +.align 2 +uihandlebelltest: +lpad 13 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la a0,bellchannel +la a1,belloffmsg +li a7,129 +ecall # User entered '1', command bell to off +1: li t0,'2' +bne a0,t0,1f +la a0,bellchannel +la a1,bellonmsg +li a7,129 +ecall # User entered '2', command bell to on +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,9 +sb t0,0(t1) # User entered '0', go to output test (page 9) +1: ret + +.align 2 +uidrawgatetest: +lpad 14 +la a0,uigatetest +li a7,4 +ecall +ret + +.align 2 +uihandlegatetest: +lpad 14 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la a0,gatechannel +la a1,gateupmsg +li a7,129 +ecall # User entered '1', command gate to up +1: li t0,'2' +bne a0,t0,1f +la a0,gatechannel +la a1,gatedownmsg +li a7,129 +ecall # User entered '2', command gate to down +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,9 +sb t0,0(t1) # User entered '0', go to output test (page 9) +1: ret + +.align 2 +uidrawstatistics: +lpad 15 +cm.push {ra},-16 +la a0,uistatistics+21 +rdcycle a1 +call hexdump +la a0,uistatistics+39 +rdtime a1 +call hexdump +la a0,uistatistics+57 +rdinstret a1 +call hexdump +la a0,uistatistics +li a7,4 +ecall +cm.popret {ra},16 + +.align 2 +uihandlestatistics: +lpad 15 +li a7,132 +ecall # Read one character of input +li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,8 +sb t0,0(t1) # User entered '0', go to diagnostics (page 8) +1: ret + +.align 2 +uidrawabout1: +lpad 16 +la a0,uiabout1 +li a7,4 +ecall +ret + +.align 2 +uihandleabout1: +lpad 16 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la t1,uipage +li t0,16 +sb t0,0(t1) # User entered '1', go to about 2 (page 16) +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,1 +sb t0,0(t1) # User entered '0', go to main menu (page 1) +1: ret + +.align 2 +uidrawabout2: +lpad 17 +la a0,uiabout2 +li a7,4 +ecall +ret + +.align 2 +uihandleabout2: +lpad 17 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la t1,uipage +li t0,17 +sb t0,0(t1) # User entered '1', go to about 3 (page 17) +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,1 +sb t0,0(t1) # User entered '0', go to main menu (page 1) +1: ret + +.align 2 +uidrawabout3: +lpad 18 +la a0,uiabout3 +li a7,4 +ecall +ret + +.align 2 +uihandleabout3: +lpad 18 +li a7,132 +ecall # Read one character of input +li t0,'1' +bne a0,t0,1f +la t1,uipage +li t0,18 +sb t0,0(t1) # User entered '1', go to about 4 (page 18) +1: li t0,'0' +bne a0,t0,1f +la t1,uipage +li t0,1 +sb t0,0(t1) # User entered '0', go to main menu (page 1) +1: ret + +.align 2 +uidrawabout4: +lpad 19 +la a0,uiabout4 +li a7,4 +ecall +ret + +.align 2 +uihandleabout4: +lpad 19 +li a7,132 +ecall # Read one character of input li t0,'0' bne a0,t0,1f la t1,uipage @@ -459,19 +830,32 @@ sb t0,0(t1) # User entered '0', go to main menu (page 1) 1: ret uidrawpointers: .word uidrawidle,uidrawmainmenu,uidrawcountryselect,uidrawadjusttiming,uidrawgatedropdelay,uidrawinitialtime,uidrawextensiontime,uidrawinvalidinput,uidrawdiagnostics +.word uidrawoutputtest,uidrawlighttest,uidrawsignaltest,uidrawbelltest,uidrawgatetest,uidrawstatistics,uidrawabout1,uidrawabout2,uidrawabout3,uidrawabout4 + uihandlepointers: .word uihandleidle,uihandlemainmenu,uihandlecountryselect,uihandleadjusttiming,uihandlegatedropdelay,uihandleinitialtime,uihandleextensiontime,uihandleinvalidinput,uihandlediagnostics +.word uihandleoutputtest,uihandlelighttest,uihandlesignaltest,uihandlebelltest,uihandlegatetest,uihandlestatistics,uihandleabout1,uihandleabout2,uihandleabout3,uihandleabout4 uipage: .byte 0 uiidle: .asciz "\nRailroad Crossing 2\nfor RVController\nMode: ??\n\nPress 'm' for menu\n'a' to activate now" uiactive: .asciz "\nRailroad Crossing 2\nfor RVController\nMode: ??\nCrossing is active\n\nPress 'm' for menu" -uimainmenu: .asciz "\nMAIN MENU\n1: Change Country\n2: Adjust Timing\n3: Diagnostics\n\n0: Exit" +uimainmenu: .asciz "\nMAIN MENU\n1: Change Country\n2: Adjust Timing\n3: Diagnostics\n4: About\n0: Exit" uicountryselect: .asciz "\nCHANGE COUNTRY\n1: Germany\n2: United Kingdom\n3: United States\n\n0: Cancel" uiadjusttiming: .asciz "\nADJUST TIMING\n1: Gate Drop Delay\n2: Init. Active Time\n3: Extension Time\n\n0: Back" uigatedropdelay: .asciz "\nGATE DROP DELAY\n\nCurrent: XX sec\n\nEnter new time or\n'c' to cancel:" uiinitialtime: .asciz "\nINIT. ACTIVE TIME\n\nCurrent: XX sec\n\nEnter new time or\n'c' to cancel:" uiextensiontime: .asciz "\nEXTENSION TIME\n\nCurrent: XX sec\n\nEnter new time or\n'c' to cancel:" uiinvalidinput: .asciz "\nInvalid entry\n\nPress any key\n\n\n" -uidiagnostics: .asciz "\nDIAGNOSTICS\n1: Output Test\n\n\n\n0: Back" +uidiagnostics: .asciz "\nDIAGNOSTICS\n1: Output Test\n2: Statistics\n\n\n0: Back" +uioutputtest: .asciz "\nOUTPUT TEST\n1: Road Signal\n2: Rail Signal\n3: Bell\n4: Gate\n0: Back" +uilighttest: .asciz "\nROAD SIGNAL TEST\n1: Off | 2: Red\n3: Yellow | 4: Green\n5: Flash Red\n6: Flash Yellow\n0: Back" +uisignaltest: .asciz "\nRAIL SIGNAL TEST\n1: Off | 2: Red\n3: Yellow | 4: Green\n5: Flash Red\n6: Flash Yellow\n0: Back" +uibelltest: .asciz "\nBELL TEST\n1: Off\n2: On\n\n\n0: Back" +uigatetest: .asciz "\nGATE TEST\n1: Up\n2: Down\n\n\n0: Back" +uistatistics: .asciz "\nSTATISTICS\n cycle: XXXXXXXX\n time: XXXXXXXX\ninstret: XXXXXXXX\n\n0: Back" +uiabout1: .asciz "\nABOUT\nRailroad Crossing 2\nfor RVController\n\n\n1: Next | 0: Exit" +uiabout2: .asciz "\nA product of\nScheiße & Broken\nSignalling Systems,\na Cheapie Systems\ncompany\n1: Next | 0: Exit" +uiabout3: .asciz "\nThis is free and\nunencumbered\nsoftware released\ninto the public\ndomain\n1: Next | 0: Exit" +uiabout4: .asciz "\nFor full license\ntext, see the\nincluded LICENSE\nfile, or visit\nunlicense.org\n0: Exit" uide: .asciz "DE" uiuk: .asciz "UK" uius: .asciz "US" diff --git a/assembly/rrxing2/util.S b/assembly/rrxing2/util.S index 9dda1ab..4d55c6b 100644 --- a/assembly/rrxing2/util.S +++ b/assembly/rrxing2/util.S @@ -1,3 +1,8 @@ +# Railroad Crossing 2 for RVController - Utility Functions and Macros +# A product of Scheiße & Broken Signalling Systems, a Cheapie Systems company +# This is free and unencumbered software released into the public domain. +# See http://unlicense.org/ for more information + .macro digiline_send channel msg la a0,(\channel) la a1,(\msg) @@ -33,6 +38,7 @@ .endm set_timer: +# Expects a number of seconds in a0 li t0,0x80 csrs mie,t0 # unmask timer interrupt ld t1,2(gp) # read mtime @@ -41,3 +47,21 @@ sltu t0,t1,a0 # check if it overflowed add t2,t2,t0 # add the overflow into the high half if there was any sd t1,10(gp) # set mtimecmp to the target value ret + +hexdump: +# Expects a pointer to the output location in a0 and a number in a1, always outputs 8 digits +li t0,7 +1: li t1,0xf +slli t2,t0,2 # Multiply digit number by 4 to get shift amount +sll t1,t1,t2 # Shift mask over to the necessary digit +and t1,t1,a1 # Get the necessary digit +srl t1,t1,t2 # Move it to the ones place +addi t1,t1,0x30 # Try converting it to an ASCII digit +li t2,0x3a +blt t1,t2,2f # If it's out of range... +addi t1,t1,7 # ...turn it into a letter +2: sb t1,0(a0) # Write out the digit +addi a0,a0,1 # Advance the pointer +addi t0,t0,-1 +bgez t0,1b +ret -- cgit v1.2.3