Geekboy

Untitled

Feb 6th, 2013
73
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.  ld a,(sword+1) ; load a with the frame pending flag byte
  33.  bit 7,a             ; if the msb is set we have a frame
  34.  jp z,QUITBAD  
  35.  ; Assumign theta for The real var removing from wiki now
  36.  ld hl,IDRealName
  37.  rst 20h
  38.  bcall(chkfindsym)
  39.  jr c,QUITBAD
  40.  xor a
  41.  cp b
  42.  jr nz,QUITBAD
  43.  inc de \ inc de ; Load to the actual data we want not the realvar info
  44.  ex de,hl
  45.  ld de,$87fa
  46.  ld bc,5
  47.  ldir
  48.  
  49.  
  50.  ld hl,sc1
  51.  rst 20h
  52.  bcall(chkfindsym)
  53.  jr c,QUITBAD
  54.  xor a
  55.  cp b
  56.  jr nz,QUITBAD
  57.  ex de,hl
  58.  and 1fh
  59.  cp 4
  60.  jr z,SString
  61.  cp 1
  62.  jr z,SList
  63.  jr BadQuit
  64. SString:      ;Set (frame) to 0 ; Also get size from list and +3 to it for frame length
  65.  ld a,0
  66.  ld de,sdat    ; overwrite vat pointer (lol who uses those) with sdat
  67.  ld (de),a     ; load first byte of frame with 1
  68.  inc de
  69.  ld c,(hl)
  70.  inc hl
  71.  ld b,(hl)
  72.  dec hl
  73.  push bc
  74.   inc bc
  75.   inc bc
  76.   inc bc
  77.   ld (sword),bc
  78.  pop bc
  79.  ldir
  80.  ld a,0
  81.  bcall(_setxxop1)
  82.  set 7,(sword+1)
  83.  ret
  84. SList:        ; Set (frame) to 1
  85.  ld a,1
  86.  ld de,sdat    ; overwrite vat pointer (lol who uses those) with sdat
  87.  ld (de),a     ; load first byte of frame with 1
  88.  inc de
  89.  ld c,(hl)  ; dont need the whole thing as this can not be over 28
  90.   ld a,c
  91.   cp 29
  92.   jr nc,QUITBAD   ; quit if over 28
  93.   add a,a
  94.   add a,a
  95.   add a,a
  96.   add a,c
  97.   ld c,a
  98.   ld b,0
  99.   inc a
  100.   inc a
  101.   push bc
  102.    inc a
  103.    ld (sword),a
  104.   pop bc
  105.  ; hl = var data
  106.  ; bc = length of var.
  107.  ; de = cn2 buffer
  108.  ldir
  109.  ld a,0
  110.  bcall(_setxxop1)
  111.  set 7,(sword+1)
  112.  ret
  113. dbfCn2BASICGet:             ;INCOMPLETE
  114. ; Check to see if there is a frame.
  115. ; if there is parse the frame and write out
  116. ; id gets copied into the String
  117. ; List gets copied into the list
  118.  
  119.  
  120. ; we are sending raw variable data in the frames
  121. ; So if it is a list add it to a list if it is a string add it to a string
  122. ; MAKE SURE WE HAVE ENOUGH Ram for this
  123.  
  124. ;Order of routine.
  125. ;   Check for pending frame  [x]
  126. ;   MTROC ID string8    
  127. ;   Copy ID over
  128. ;   Check Data Type
  129. ;   MTROC Appropriate variable  (LCn2,Str9)
  130. ;   Copy Data over
  131. ;   Clear Frame Pending
  132. ;   Ret
  133. ; set ans to 0 if frame was recieved
  134.  
  135.  ld a,(rword+1) ; load a with the incoming flag byte
  136.  bit 7,a             ; if the msb is set we have a frame
  137.  jp z,QUITBAD               ; if its not quit
  138.  ld hl,IDrealName
  139.  ld a,1                  ;delete and create theta.
  140.  ld (RVarLength),a
  141.  call DeleteAndCreate
  142.  push de                ; save data pointer so we can write the id to it later
  143.   ld a,(rdat)          ; load a with frame id
  144.   or a    ;if 0 we have a string if one we have a list.
  145.   jp nz,ldlist          ; if list div length by nine
  146.   ld a,(Rword)
  147.   sub 1                 ; if string calculate length
  148.   ld (RVarLength),a
  149.   ld hl,DataStringName
  150.   jr Copydata
  151. ;kinda just shoved this here. Makes following it a pain but do I really care?
  152. ; nothing traverses here it all jumps over it. Woo dead space
  153. QUITBAD:
  154.  ;returns 1 if we failed. reusable routine.
  155.  ld a,1
  156.  bcall(_setxxop1)
  157.  ret  
  158. ldlist:
  159.   ld a,(rword)
  160.   dec a
  161.   ld b,0
  162. Div9Loop:
  163.   inc b
  164.   sub 9
  165.   jr z,Div9Done
  166.   jr nc,div9loop
  167. Div9Done:
  168.   ld a,b
  169.   ld (RVarLEngth),a
  170.   ld hl,DataListName
  171.  
  172.  
  173. CopyData:
  174.   Call DeleteAndCreate
  175.   ;get data length -1 -> bc
  176.   ld a,(rword)      ; get length from frame and store into bc
  177.   dec a
  178.   ld c,a
  179.   ld b,0
  180.   ld hl,(rdat+1)    ; load hl with pointer to frame+1 for variable data
  181.   ldir
  182.  pop de
  183. ;here i handle the real this should be rather easy
  184. ;we are interested in just the first 5 values in the mantessa
  185. ; the mantessa is de+2
  186. ; so lets initialise our variable
  187.  ld hl,$0080     ;standard exponent and no negative? i think we will see
  188.  inc de \ inc de
  189. ;Now the next 5 bytes are our id.
  190.  ld bc,5
  191.  ld hl,($86F3)   ; recieve id
  192.  ldir
  193. ;theta now has the user id in it
  194.  ld hl,RWord+1
  195.  res 7,(hl)
  196.  ; aknowledge we got a frame and quit
  197.  ld a,0
  198.  bcall(_setxxop1)
  199.  ret
  200.  ;according to iambian and some of kerms code this is supposed to return the value of op1 in ans �\(�_o)/�
  201.  ; jp XlibEndNoOut
  202. DeleteAndCreate
  203. ;expects pointer to variable name in hl
  204. ;destroys all
  205. ;returns pointer to variable data in de
  206.  push hl
  207.   rst 20h  ;load op1 with variable name
  208.   bcall(_chkfindsym)
  209.   jr c,create
  210.   ld hl,op1             ; I belive i need to do this for delvararc.
  211.   bcall(_DelVarArc)   ;delete if since it exists
  212. Create:
  213.  pop hl
  214.  ld a,(hl)
  215.  ld hl,(RVarLength)
  216.  bcall(_createvar)
  217.  ret
  218.  
  219.  
  220.  
  221.  
  222.  
  223. DataStringName:
  224.  .db strngOBJ,tVarStrng,tstr9,$0
  225. IDRealName:
  226.  .db $0,tTheta,$0,$0
  227. DataListName:
  228.  .db $01,tVarLst,tC,tN,t2,$0
  229.  
  230. dbfCn2BASICStop:                ;Main Functions Complete
  231.  ld a,(nargs)
  232.  cp 2
  233.  jp nz,xLIBEndNoOut
  234.  ld A,(var1)
  235.  cp 1
  236.  jr nz,{@}    ; If enabled, skip over enabling
  237.  call enablecn2
  238.  jr {2@}
  239. @:  
  240.  call disablecn2
  241. @:
  242.  jp xLIBEndNoOut   
  243. EnableCn2:
  244. ;Disable APD Setup Cn2.2 Hook TiOs intterupt.
  245.  di
  246.  bcall(4C84h)            ;Disable APD  ( DO we even use ti83+.inc???
  247.  call Cn2_Setup
  248.  ld hl,0038
  249.  ld (Cn2_Hook_Pre),HL   ; Hopefully chain The tios intterupt before the calcnet intterupt.
  250.                           ; Personally wondering if this should be at the end of the calcnet intterupt.
  251.                           ; only because of how the tios intterupt is unpredicable in length.
  252.                           ; Do we really have to worry about that?? According to kerm I do not
  253.  
  254.  set 3,(iy+33h)           ; ignoreBPlink          
  255.  res 4,(iy+33h)           ; BPLinkOn      Disable link Assist for sure
  256.  res 0,(iy+3Eh)           ;                Disables Silent linking supposedly  
  257.  ld a,%00000001
  258.  out (08),a               ;Disable link assist via ports want as much cushion as possible here.
  259.  ei
  260.  jp xLIBEndNoOut
  261.  
  262. DisableCn2:
  263.  di
  264.  call Cn2_Setdown
  265.  res 3,(iy+33h)           ; ignoreBPlink          
  266.  set 4,(iy+33h)           ; BPLinkOn      Enable Silent linking and link assist
  267.  set 0,(iy+3Eh)  
  268.  ld a,0
  269.  out (08),a               ; Reenable link assist disable intterupts
  270.  bcall($4C87)              ; Enable Apd again
  271.  ei
  272.  jp xLibEndNoOut
Advertisement
Add Comment
Please, Sign In to add comment