Geekboy

Untitled

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