nmractrl res 1 ; state relevant to NMRA control
transmitbit equ 7 ; bit 7: 0/1 bit currently being transmitted
nextaction equ 6 ; bit 6: change polarity on next interrupt y/n
+ ; nmractrl is a bitmask, and only the bits above are used
fromserial res 1 ; from-serial buffer location (in buffer bank)
totrack res 1 ; to-track buffer location (in buffer bank)
totrackbit res 1 ; bit location of pointer within byte
+ ;
+ ; buffers are each 16 bytes (this is hardwired)
+ ; and there are four of them starting at 0x500, 0x510, 0x520, 0x530.
+ ;
+ ; fromserial and totrack are pointers into the buffer page
+ ;
+ ; fromserial points to the first empty byte, where we will put new
+ ; data provided by the host; this means that (fromserial & 0xf0) is
+ ; the first buffer which fails to contain a complete nmra message
+ ;
+ ; totrack points to the first remaining full byte, which is currently
+ ; being transmitted; if nothing is currently being transmitted
+ ; because there is no nmra data at all then totrack points to the
+ ; start of the same buffer as fromserial
bufferpage equ 5