RS422 conversion fron Bascom

Hi.
I was working with Bascom Basic up to a few months ago then migrated to a better life with the Arduino family.
I have been interested in ROV’s (Remotely operated underwater vehicle)
And I used the program below to send and recieve data to the Sub.
Redoing the Bascom into Arduino and wanted some pointers. As you can see by the number of post I have made I am still a novice with Arduino.
The area I am not sure about I have highlighted with RED Dogh Code will not highlight Used %%%%%%%%%% to highlight the area.
I am sure there will be a lot more but I will have a bash and get most of the conversion done first.

Const Usesimulator = 1                                   'enable simulator
       $regfile = "m8535.dat."
       $sim
       $crystal = 8000000
$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 20                                               ' default use 10 for the SW stack
$framesize = 40                                             ' default use 40 for the frame space
'LCD defults for my ATM8535 chip
Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.1 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
Config Lcd = 20 * 4
$baud = 9600
Declare Sub Rs422output()
Declare Sub Displayvarables()
Declare Sub Processdata()

'---[ Define RS422 Send/Receive parameters]---
Const _endofpacket = &HFF                                   'End of packet flag
Const _packetlengthin = 11                                  'used for input packet
Dim Outdata(20) As Byte                                     'rs422 send data
Dim Indata(20) As Byte                                      'rs422 receive data
Dim Outbits As Byte                                         'used for checksum
Dim Packetoutloop As Byte                                   'used for sending data
Dim Endofpacket As Bit                                      'Has end of packet char been seen
Dim Serialchar As Byte                                      'serial input char
Dim Packetinloop As Byte                                    'serial input char counter
Dim Highlow As Word                                         'used in byte->word conversion
Dim Hi As Byte At Highlow Overlay  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Dim Lo As Byte At Highlow + 1 Overlay  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Dim Onesecond As Bit                                        'set once a second
Const Secondvalue1 = 34285

Dim Joylr As Long
Dim Joyfr As Long
Dim Depth_wanted As Long
Dim Camera As Integer
Dim Adjust As Byte
Dim Leftthruster As Word                                    'sent data
Dim Rightthruster As Word                                   'sent data
Dim Depth As Word
Dim Cameraservo As Word
Dim Spare As Word                                           ' Spare Word
Dim Sw1 As Bit                                              'Spare Bit
Dim Sw2 As Bit                                              'Spare Bit
Dim Sw3 As Bit                                              'Spare Bit


'---[ Use a serial IN/OUT buffer ]-----------
#if Usesimulator = 0                                        'buffered I/O does not work in simulator
  Config Serialin = Buffered , Size = 20                    'use a serial buffer - input
  Config Serialout = Buffered , Size = 20                   'use a serial buffer - output
#endif
Packetinloop = 1                                            'Set start of input buffer

'---[ Setup 1 second timer tick ]------------
Config Timer1 = Timer , Prescale = 256                      'setup tick timer
On Ovf1 Tim1_isr Nosave                                     'setup ISR entry point
Timer1 = Secondvalue1                                       'define reload value  ==========================

Cls
Locate 2 , 5 : Lcd "Tony's RoV" : Wait 5

Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Porta.3 = Input                                      'increase depth
Config Porta.4 = Input                                      'decrease depth
 Camera = 2985
 Adjust = 50
 Spare = 234
 Sw1 = 1
 Sw2 = 1
 Sw3 = 1


 Do
 If Onesecond = 1 Then                                      'once a second
      Call Rs422output                                      'send data
      Reset Onesecond
   End If

Joyfr = Getadc(0)
Joyfr = Joyfr * 36468 : Joyfr = Joyfr / 10000 : Joyfr = Joyfr + 1120       'Scales the ADC input to  1120 - 2985 - 4850
Joylr = Getadc(1)
Joylr = Joylr * 36468 : Joylr = Joylr / 10000 : Joylr = Joylr + 1120
Depth_wanted = Getadc(2)
Depth_wanted = Depth_wanted * 36468 : Depth_wanted = Depth_wanted / 10000 : Depth_wanted = Depth_wanted + 1120
If Pina.3 = 0 Then                                          'increase depth
Camera = Camera + Adjust
End If
If Pina.4 = 0 Then                                          'decrease depth
Camera = Camera - Adjust
End If
If Camera < 1120 Then Camera = 1120
If Camera > 4850 Then Camera = 4850

Cameraservo = Camera                                        'Sent data
Leftthruster = Joyfr                                        'Sent data
Rightthruster = Joylr                                       'Sent data
Depth = Depth_wanted                                        'Sent data

Loop

 Sub Rs422output()                                          'make data packet to be sent
  Outdata(1) = Low(leftthruster)
  Outdata(2) = High(leftthruster)
  Outdata(3) = Low(rightthruster)
  Outdata(4) = High(rightthruster)
  Outdata(5) = Low(depth)
  Outdata(6) = High(depth)
  Outdata(7) = Low(cameraservo)
  Outdata(8) = High(cameraservo)
  Outdata(9) = Low(spare)
  Outdata(10) = High(spare)
  Outbits.1 = Sw1                                           'copy all bits into one byte
  Outbits.2 = Sw2
  Outbits.3 = Sw3
  Outbits.4 = 0
  Outdata(11) = Outbits                                     'and save them
  Outbits = 0                                               '******************************************
  For Packetoutloop = 1 To 11                               'generate checksum
    Outbits = Outbits + Outdata(packetoutloop)
    Print ; Chr(outdata(packetoutloop)) ;                   'Send to serial port
  Next Packetoutloop
  Print ; Chr(outbits);                                     'send checksum
  Print ; Chr(_endofpacket) ; Chr(_endofpacket);            'send end of packet flag
End Sub

'------------------------------------------------------------
Tim1_isr:
  push r24
  push r25
  in r24, SREG                                              'don't forget sreg
  push r24
  Timer1 = Secondvalue1                                     'setup timer for next overflow
  Set Onesecond                                             'set 1 second flag
  pop r24                                                   'restore the
  !Out Sreg , R24                                           'remaing registers
  pop r25
  pop r24
Return

Regards Antony

Dim Highlow As Word                                         'used in byte->word conversion

This declares a variable that is the same size as an int on the Arduino.

Dim Hi As Byte At Highlow Overlay  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Dim Lo As Byte At Highlow + 1 Overlay  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Use the lowByte() and highByte() functions, or bit shifting, to accomplish the same task.

Hi Thanks for that...It's the bitshift that I was missing.

Regards Antony