Geekboy

Untitled

Mar 7th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. ;============================
  2. fBinRead:
  3. ld hl,(var2) ;get Y
  4. ld a,l ;check
  5. or h ;if zero
  6. jp z,Err.NULLVAR ;If zero, then error condition; not reading any bytes
  7. push hl ;store # of bytes to read
  8. add hl,hl ;double this for string recall creation
  9. call makestring+3 ;create Str9 with as many bytes as hex digits
  10. push de ;save position of string
  11. ld hl,(var3)
  12. ld a,(sargs)
  13. or a
  14. jr z,$+5
  15. call getprogram ;locate program variable
  16. ld de,(var1) ;store back nth byte
  17. call AddDEtoHL ;get position to start reading from
  18. push hl
  19. bcall(_Op4toOp1)
  20. pop hl
  21. pop de ;restore position of the string
  22. pop bc ;restore # of bytes to read as BC for looping
  23. jp BinStringToHex
  24.  
  25. getprogramname:
  26. ld hl,sc1
  27. call getsourcestring ;skip over the "LD HL,Str9" part
  28. jp z,Err.NULLVAR ;Str0 is null. Cannot accept input.
  29. ex de,hl
  30. ld hl,-22 ;This number picked to prevent terrible buffer overflow
  31. add hl,bc ;Can't be too long.
  32. jp c,Err.ENTRYTOOLONG
  33. ld hl,Op1
  34. ld a,(de) ;DE=input string. first byte
  35. cp $15 ;rowSwap( token equates to AppVar type
  36. jr z,skip923 ;jump over in order to copy in the type byte as well
  37. bit gList,(iy+myflag)
  38. jr z,skip922
  39. cp $5D ;official list token. L1 thru L6
  40. jr z,$+6 ;skip to handling list
  41. cp $EB ;list token used to name user-defined lists
  42. jr nz,skip922 ;skip to comparing all else if this is not a list
  43. ld (hl),$01 ;type byte for rList
  44. inc hl
  45. ld a,$5D ;list type
  46. ld (hl),a
  47. inc hl ;increment pointer to fill in list name data
  48. inc de ;increment pointer to get list name data
  49. dec bc ;decrement size of data for the list.
  50. jr skip923
  51. skip922:
  52. bit gGroup,(iy+myflag) ;
  53. jr z,$+7 ;
  54. ld a,(de) ;
  55. cp $17 ;*row( token equates to Group type
  56. jr z,skip923 ;
  57. ld (hl),$05 ;Prog obj
  58. inc hl
  59. skip923:
  60. ex de,hl
  61. ld b,c ;
  62. getprognamesubloop: ;
  63. ld a,(hl) ;
  64. inc hl ;
  65. cp $BB ;
  66. jr nz,getprognameminloop ;2bytetok skip if not found.
  67. ld a,(hl) ;
  68. inc hl ;
  69. dec b ;
  70. cp $BB ;byte not repeated in series. Skipping $BB in series.
  71. jr c,$+3 ;because of that, if less than that num, do not alter num
  72. dec a ;
  73. sub $B0-$61 ;decrease by appropriate number of bytes. Yeah.
  74. getprognameminloop: ;
  75. ld (de),a ;
  76. inc de ;
  77. djnz getprognamesubloop ;
  78. xor a ;would not reach this point if A!=0. See "LD A,B" earlier.
  79. ld (de),a ;clear out next byte for null-terminated string
  80. bcall(_ChkFindSym) ;check for program with name retrieved from Str0
  81. jr nc,$+30 ;skip if program info is found. Else, search for hidden
  82. ld hl,Op1+1 ;
  83. ld a,(hl) ;
  84. add a,-$40 ;
  85. ld (hl),a ;
  86. bcall(_ChkFindSym) ;
  87. jr c,$+8 ;
  88. set Hidden,(IY+myflag) ;
  89. jr $+12 ;
  90. push af ;
  91. ld a,(Op1+1) ;
  92. add a,$40 ;set back to normal
  93. ld (Op1+1),a ;
  94. pop af ;
  95. ret
  96.  
  97. getprogram: ;outputs and resets vectors for program data using Str0 stuffs.
  98. call getprogramname
  99. jp c,Err.PRGMNOTFOUND ;kill program with this error if program is not found
  100. ex de,hl
  101. ld a,b
  102. ld (cpage),a
  103. or a
  104. jr z,$+15 ;2 skip if already unarchived
  105. ld de,9 ;3
  106. call addDEtoHL ;3
  107. call getHLinc ;3
  108. ld e,a ;1 ,D already set to zero
  109. call addDEtoHL ;3 = 15
  110. getvarcoll:
  111. ld (SOF),hl ;address at start of size field
  112. call getHLinc
  113. ld e,a
  114. call getHLinc
  115. ld d,a
  116. ld a,(cpage)
  117. ; ld (SOF+2),a ;page
  118. push af
  119. push hl
  120. call addDEtoHL ;add in size and compensate for page stuffs if in Flash
  121. ld (EOF),hl ;address
  122. ld a,(cpage)
  123. ld (EOF+2),a ;page
  124. pop hl
  125. pop af
  126. ld (cpage),a
  127. ret
Advertisement
Add Comment
Please, Sign In to add comment