Geekboy

Untitled

Feb 5th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;==============================================
  2.  
  3. #define  Cn2_Setup          $4209
  4. #define  Cn2_Clear_SendBuf  $420C
  5. #define  Cn2_Clear_RecBuf   $420F
  6. #define Cn2_Setdown         $4212
  7. #define Cn2_GetK            $4221
  8. #define SWord               $87FF
  9. #define Rword               $86F8
  10. #define Sdat                $8801
  11. #define Rdat                $86FA
  12. #define rvarlength          $9872+176   ; put at the end of appbackupscreen right after iambians variable only because idk what he is doing there so best safe then sorry
  13. dbfCn2BASICSend:            ;INCOMPLETE
  14. ;Check arguments
  15. ; order is
  16. ; ID
  17. ; Data
  18. ; ID is any real variable preferably theta for simplicities sake
  19. ; Data can be a string of a list. gonna have to parse the vat for just the type and put a 1/0 in for type
  20. ; after thats parsed its a simple copy of the real to the ip part
  21. ; the size is copied from the data pointer
  22. ; for lists its (multx9)+1
  23. ; for strings its length+1
  24.  
  25. ;   Order of stuff
  26. ; Check for pending frame if one quit early (send status code?)
  27. ; Set up buffers
  28. ; set up sizes
  29. ; mark pending
  30. ; set ans to 1 if frame was set to 0 if not
  31. ; quit
  32.     jp $
  33.     jp xLIBEndNoOut
  34. dbfCn2BASICGet:             ;INCOMPLETE
  35. ; Check to see if there is a frame.
  36. ; if there is parse the frame and write out
  37. ; id gets copied into the String
  38. ; List gets copied into the list
  39.  
  40.  
  41. ; we are sending raw variable data in the frames
  42. ; So if it is a list add it to a list if it is a string add it to a string
  43. ; MAKE SURE WE HAVE ENOUGH Ram for this
  44.  
  45. ;Order of routine.
  46. ;   Check for pending frame  [x]
  47. ;   MTROC ID string8    
  48. ;   Copy ID over
  49. ;   Check Data Type
  50. ;   MTROC Appropriate variable  (LCn2,Str9)
  51. ;   Copy Data over
  52. ;   Clear Frame Pending
  53. ;   Ret
  54. ; set ans to 0 if frame was recieved
  55.  
  56.  ld a,(rword+1) ; load a with the incoming flag byte
  57.  bit 7,a             ; if the msb is set we have a frame
  58.  jp z,xLIBEndNoOut               ; if its not quit
  59.  ld hl,IDrealName
  60.  ld a,1                  ;delete and create theta.
  61.  ld (RVarLength),a
  62.  call DeleteAndCreate
  63.  push de                ; save data pointer so we can write the id to it later
  64.   ld a,(rdat)          ; load a with frame id
  65.   or a    ;if 0 we have a string if one we have a list.
  66.   jp nz,ldlist          ; if list div length by nine
  67.   ld a,(Rword)
  68.   sub 1                 ; if string calculate length
  69.   ld (RVarLength),a
  70.   ld hl,DataStringName
  71.   jr Copydata
  72.  
  73.  
  74. ldlist:
  75.   ld a,(rword)
  76.   dec a
  77.   ld b,0
  78. Div9Loop:
  79.   inc b
  80.   sub 9
  81.   jr z,Div9Done
  82.   jr nc,div9loop
  83. Div9Done:
  84.   ld a,b
  85.   ld (RVarLEngth),a
  86.   ld hl,DataListName
  87.  
  88.  
  89. CopyData:
  90.   Call DeleteAndCreate
  91.   ;get data length -1 -> bc
  92.   ld a,(rword)      ; get length from frame and store into bc
  93.   dec a
  94.   ld c,a
  95.   ld b,0
  96.   ld hl,(rdat+1)    ; load hl with pointer to frame+1 for variable data
  97.   ldir
  98.  pop de
  99. ;here i handle the real this should be rather easy
  100. ;we are interested in just the first 5 values in the mantessa
  101. ; the mantessa is de+2
  102. ; so lets initialise our variable
  103.  ld hl,$0080     ;standard exponent and no negative? i think we will see
  104.  inc de \ inc de
  105. ;Now the next 5 bytes are our id.
  106.  ld bc,5
  107.  ld hl,($86F3)   ; recieve id
  108.  ldir
  109. ;theta now has the user id in it
  110.  ld hl,RWord+1
  111.  res 7,(hl)
  112.  ; aknowledge we got a frame and quit
  113.  jp XlibEndNoOut
  114. DeleteAndCreate
  115. ;expects pointer to variable name in hl
  116. ;destroys all
  117. ;returns pointer to variable data in de
  118.  push hl
  119.   rst 20h  ;load op1 with variable name
  120.   bcall(_chkfindsym)
  121.   jr c,create
  122.   bcall(_DelVarArc)   ;delete if since it exists
  123. Create:
  124.  pop hl
  125.  ld a,(hl)
  126.  ld hl,(RVarLength)
  127.  bcall(_createvar)
  128.  ret
  129.  
  130.  
  131.  
  132.  
  133.  
  134. DataStringName:
  135.  .db strngOBJ,tVarStrng,tstr9,$0
  136. IDRealName:
  137.  .db $0,tTheta,$0,$0
  138. DataListName:
  139.  .db $01,tVarLst,tC,tN,t2,$0
  140.  
  141. dbfCn2BASICStop:                ;Main Functions Complete
  142.  ld a,(nargs)
  143.  cp 2
  144.  jp nz,xLIBEndNoOut
  145.  ld A,(var1)
  146.  cp 1
  147.  jr nz,{@}    ; If enabled, skip over enabling
  148.  call enablecn2
  149.  jr {2@}
  150. @:  
  151.  call disablecn2
  152. @:
  153.  jp xLIBEndNoOut   
  154.    
  155. EnableCn2:
  156. ;Disable APD Setup Cn2.2 Hook TiOs intterupt.
  157.  di
  158.  bcall(4C84h)            ;Disable APD  ( DO we even use ti83+.inc???
  159.  call Cn2_Setup
  160.  ld hl,0038
  161.  ld (Cn2_Hook_Pre),HL   ; Hopefully chain The tios intterupt before the calcnet intterupt.
  162.                           ; Personally wondering if this should be at the end of the calcnet intterupt.
  163.                           ; only because of how the tios intterupt is unpredicable in length.
  164.                           ; Do we really have to worry about that?? According to kerm I do not
  165.  
  166.  set 3,(iy+33h)           ; ignoreBPlink          
  167.  res 4,(iy+33h)           ; BPLinkOn      Disable link Assist for sure
  168.  res 0,(iy+3Eh)           ;                Disables Silent linking supposedly  
  169.  ld a,%00000001
  170.  out (08),a               ;Disable link assist via ports want as much cushion as possible here.
  171.  ei
  172.  ret
  173.  
  174. DisableCn2:
  175.  di
  176.  call Cn2_Setdown
  177.  res 3,(iy+33h)           ; ignoreBPlink          
  178.  set 4,(iy+33h)           ; BPLinkOn      Enable Silent linking and link assist
  179.  set 0,(iy+3Eh)  
  180.  ld a,0
  181.  out (08),a               ; Reenable link assist disable intterupts
  182.  bcall($4C87)              ; Enable Apd again
  183.  ei
  184.  ret
Advertisement
Add Comment
Please, Sign In to add comment