Geekboy

Untitled

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