One last bit of code to run past the brain trust before I shelve this project and move on to more productive pursuits.
Part of my analysis of this code (and commenting my way through the source dump I made) was with intent of being able to reproduce the functionality on newer platforms, but I am finding that there are a few critical pieces of code that are too tightly bound to the M68xx architecture to translate easily to newer languages. Absent an actual copy of the source code from the OEM (and it being a futile task to ask for same), I have figured out enough of the code at hand to largely satisfy my curiosity.
Anyway...
There are three calls to this routine I can see in the code.
One is after a 'cold start', and Accumulator B is set to 30 ($1E) before calling this routine.
The other two instances are in the second stage of the interrupt handling, and Accumulator B is set to 0 before calling this routine.
Variables starting with NVR_ refer to the NVRAM at $0C00 (i.e., NVR_35 = $0C35), specifically those addresses whose purpose I hadn't figured out.
The range in question appears to fall within $0C33 to $0C3E.
msgPtrL seems to be some type of pointer for use by the transmitter / receiver routines in the interrupt code (it is used as either an 8-bit or 16-bit value, 8-bit in this case)
tblByte is the value returned by a lookup table (it has the odd progression of 0,1,2,4,8,65,66,15)
switch2 is one of several 'soft switches' set at the factory relating to the application.
piaPortA is port A on the 6821. In this case, it is pin PA0 we are interested in, which is the input bit stream from the receiver. That makes me think this is some sort of buffering routine?
sub_591
LDAA NVR_35
BEQ sub_59B
sub_596
ASLB
SUBA #$10
BNE sub_596
sub_59B
STAB NVR_3C
LDAB msgPtrL
STAB NVR_3B
LDAB tblByte
LDAA #switch2 ; soft switch to use full AccB or just bits 0 / 1 (current value: 0)
BEQ sub_5A9
ANDB #$03
sub_5A9
PSHB
CLRA
LDAB piaPortA
RORB
ROLA
LDAB piaPortA
RORB
ROLA
LDAB piaPortA
RORB
ROLA
PULB
PSHX
LDX #NVR_35
sub_5BB
LSRB
BCC sub_5D3
PSHB
LDAB piaPortA
RORB
ROLA
ANDA #$0F
PSHA
LDAB NVR_3C
BEQ sub_5CE
ABA
BRA sub_5CF
sub_5CE
CLRA
sub_5CF
STAA $00,X
PULA
PULB
sub_5D3
INX
TSTB
BNE sub_5BB
PULX
RTS