Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define Cn2_Setup $4209
- #define Cn2_Clear_SendBuf $420C
- #define Cn2_Clear_RecBuf $420F
- #define Cn2_Setdown $4212
- #define Cn2_GetK $4221
- #define SWord $87FF
- #define Rword $86F8
- #define Sdat $8801
- #define Rdat $86FA
- #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
- dbfCn2BASICSend: ;INCOMPLETE
- ;Check arguments
- ; order is
- ; ID
- ; Data
- ; ID is any real variable preferably theta for simplicities sake
- ; 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
- ; after thats parsed its a simple copy of the real to the ip part
- ; the size is copied from the data pointer
- ; for lists its (multx9)+1
- ; for strings its length+1
- ; Order of stuff
- ; Check for pending frame if one quit early (send status code?)
- ; Set up buffers
- ; set up sizes
- ; mark pending
- ; set ans to 1 if frame was set to 0 if not
- ; quit
- jp $
- ld a,(sword+1) ; load a with the frame pending flag byte
- bit 7,a ; if the msb is set we have a frame
- jp z,QUITBAD
- ; Assumign theta for The real var removing from wiki now 2/7/13
- ld hl,IDRealName
- rst 20h
- bcall(_chkfindsym)
- jp c,QUITBAD ; make suer theta exists
- xor a
- cp b
- jp nz,QUITBAD ; if file is in atchive quit cause im to lazy to unarchive it. Who archives realvars anyway? delvar that shit
- inc de \ inc de ; Load to the actual data we want not the realvar exponent/flagbytes
- ex de,hl ; move data pointer to hl for Ldir
- ld de,$87fa
- ld bc,5
- ldir ; copy bytes into Id
- ld hl,sc1 ; load Op1 value of passed data
- rst 20h
- bcall(_chkfindsym)
- jp c,QUITBAD
- xor a
- cp b
- jp nz,QUITBAD
- ex de,hl
- and 1fh ; A contains the element type in the lower 5 bits mask out the upper bits
- cp 4 ; if its a string
- jr z,SString ; ...
- cp 1 ; if its a list
- jr z,SList ; ...
- jp QuitBad ; if none of the above skedadle
- SString: ;Set (frame) to 0 ; Also get size from list and +3 to it for frame length
- ld a,0
- ld de,sdat ; overwrite vat pointer (lol who uses those) with sdat
- ld (de),a ; load first byte of frame with 0
- inc de
- ld c,(hl)
- inc hl
- ld b,(hl) ; load hl with the size of the string.
- dec hl ; return hl to start of the string
- inc bc
- inc bc
- inc bc ; increase it to match size+info byte length
- ld (sword),bc ; save to length proper
- dec bc ; restore size after we increase it to match size+ length bytes
- ldir
- ld a,0
- bcall(_setxxop1)
- ld a,(sword+1)
- or 80h
- ld (sword+1),a
- ret
- SList: ; Set (frame) to 1
- ld a,1
- ld de,sdat ; overwrite vat pointer (lol who uses those) with sdat
- ld (de),a ; load first byte of frame with 1
- inc de
- ld c,(hl) ; dont need the whole thing as this can not be over 28
- ld a,c ; and while yes this can leave a bug if there is over 100 elements in the list not my problem
- cp 29
- jr nc,QUITBAD ; quit if over 28
- add a,a
- add a,a
- add a,a
- add a,c ; multiply by nine
- inc a
- inc a ; increase a by 3 for when we
- inc a ; to accomodate for info byte and size bytes of variable
- ld (sword),a
- dec a ; return to var size
- ld b,0 ; make bc 00xx where xx will be C
- ld c,a ; save to C so we have 00xx proper
- ; hl = var data
- ; bc = length of var.
- ; de = cn2 buffer
- ldir ;
- ld a,0
- bcall(_setxxop1)
- ld a,(sword+1)
- or 80h
- ld (sword+1),a
- ret
- dbfCn2BASICGet: ;INCOMPLETE
- ; Check to see if there is a frame.
- ; if there is parse the frame and write out
- ; id gets copied into the String
- ; List gets copied into the list
- ; we are sending raw variable data in the frames
- ; So if it is a list add it to a list if it is a string add it to a string
- ; MAKE SURE WE HAVE ENOUGH Ram for this
- ;Order of routine.
- ; Check for pending frame [x]
- ; MTROC ID string8
- ; Copy ID over
- ; Check Data Type
- ; MTROC Appropriate variable (LCn2,Str9)
- ; Copy Data over
- ; Clear Frame Pending
- ; Ret
- ; set ans to 0 if frame was recieved
- ld a,(rword+1) ; load a with the incoming flag byte
- bit 7,a ; if the msb is set we have a frame
- jp z,QUITBAD ; if its not quit
- ld hl,IDrealName
- ld a,1 ;delete and create theta.
- ld (RVarLength),a
- call DeleteAndCreate
- push de ; save data pointer so we can write the id to it later
- ld a,(rdat) ; load a with frame id
- or a ;if 0 we have a string if one we have a list.
- jp nz,ldlist ; if list div length by nine
- ld a,(Rword)
- sub 1 ; if string calculate length
- ld (RVarLength),a
- ld hl,DataStringName
- jr Copydata
- ;kinda just shoved this here. Makes following it a pain but do I really care?
- ; nothing traverses here it all jumps over it. Woo dead space
- QUITBAD:
- ;returns 1 if we failed. reusable routine.
- ld a,1
- bcall(_setxxop1)
- ret
- ldlist:
- ld a,(rword)
- dec a
- ld b,0
- Div9Loop:
- inc b
- sub 9
- jr z,Div9Done
- jr nc,div9loop
- Div9Done:
- ld a,b
- ld (RVarLEngth),a
- ld hl,DataListName
- CopyData:
- Call DeleteAndCreate
- ;get data length -1 -> bc
- ld a,(rword) ; get length from frame and store into bc
- dec a
- ld c,a
- ld b,0
- ld hl,(rdat+1) ; load hl with pointer to frame+1 for variable data
- ldir
- pop de
- ;here i handle the real this should be rather easy
- ;we are interested in just the first 5 values in the mantessa
- ; the mantessa is de+2
- ; so lets initialise our variable
- ld hl,$0080 ;standard exponent and no negative? i think we will see
- inc de \ inc de
- ;Now the next 5 bytes are our id.
- ld bc,5
- ld hl,($86F3) ; recieve id
- ldir
- ;theta now has the user id in it
- ld hl,RWord+1
- res 7,(hl)
- ; aknowledge we got a frame and quit
- ld a,0
- bcall(_setxxop1)
- ret
- ;according to iambian and some of kerms code this is supposed to return the value of op1 in ans �\(�_o)/�
- ; jp XlibEndNoOut
- DeleteAndCreate
- ;expects pointer to variable name in hl
- ;destroys all
- ;returns pointer to variable data in de
- push hl
- rst 20h ;load op1 with variable name
- bcall(_chkfindsym)
- jr c,create
- ld hl,op1 ; I belive i need to do this for delvararc.
- bcall(_DelVarArc) ;delete if since it exists
- Create:
- pop hl
- ld a,(hl)
- ld hl,(RVarLength)
- bcall(_createvar)
- ret
- DataStringName:
- .db strngOBJ,tVarStrng,tstr9,$0
- IDRealName:
- .db $0,tTheta,$0,$0
- DataListName:
- .db $01,tVarLst,tC,tN,t2,$0
- dbfCn2BASICStop: ;Main Functions Complete
- jp $
- ld a,(nargs)
- cp 2
- jp nz,xLIBEndNoOut
- ld A,(var1)
- cp 1
- jr z,enablecn2 ; If enabled, skip over enabling
- jp disablecn2
- EnableCn2:
- ;Disable APD Setup Cn2.2 Hook TiOs intterupt.
- bcall(4C84h) ;Disable APD ( DO we even use ti83+.inc???
- di
- call Cn2_Setup
- ld hl,0038
- ld (Cn2_Hook_Pre),HL ; Hopefully chain The tios intterupt before the calcnet intterupt.
- ; Personally wondering if this should be at the end of the calcnet intterupt.
- ; only because of how the tios intterupt is unpredicable in length.
- ; Do we really have to worry about that?? According to kerm I do not
- set 3,(iy+33h) ; ignoreBPlink
- res 4,(iy+33h) ; BPLinkOn Disable link Assist for sure
- res 0,(iy+3Eh) ; Disables Silent linking supposedly
- ld a,%00000001
- out (08),a ;Disable link assist via ports want as much cushion as possible here.
- ei
- jp xLIBEndNoOut
- DisableCn2:
- call Cn2_Setdown
- di
- res 3,(iy+33h) ; ignoreBPlink
- set 4,(iy+33h) ; BPLinkOn Enable Silent linking and link assist
- set 0,(iy+3Eh)
- ld a,0
- out (08),a ; Reenable link assist disable intterupts
- bcall($4C87) ; Enable Apd again
- ei
- jp xLibEndNoOut
Advertisement
Add Comment
Please, Sign In to add comment