Geekboy

Untitled

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