home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1995 January / 1995-01b.d64 / checksum (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  55 lines

  1. 0 rem
  2. 1 rem    checksum program
  3. 2 rem    using crc checksum
  4. 3 rem    by d.pankhurst
  5. 4 rem    copyright 1995
  6. 5 rem
  7. 100 poke55,peek(45):poke56,peek(46)+6:clr
  8. 105 ms=peek(56)*256+peek(55):me=ms:re=53245
  9. 110 gosub 4300:rem init
  10. 120 gosub 4500:ifx$=""thenend:rem name
  11. 130 gosub 6800:ifefthen120:rem get file
  12. 140 gosub 6000:rem checksum
  13. 160 goto 120
  14. 4300 rem"[192][192][192]init
  15. 4305 lf[178]0:sf[178]0:cf[178]0:fp[178]1135 :cn[178]0
  16. 4310 [150] [165] h(x)[178][181](x[173]256)
  17. 4315 [150] [165] l(x)[178]x[171]([165] h(x))[172]256
  18. 4320 [150] [165] b(x)[178]x[171](x[179]0)[172]65536
  19. 4325 [150] [165] d(x)[178][194](x)[170]256[172][194](x[170]1)
  20. 4330 di$[178]"":di[178]0:[153]"load"di$:[151]53280,di:[151] 53281,di
  21. 4335 [153][163]50)"len(NULL)len  lenhecksum (NULL)rogram
  22. 4340 printtab(10)"[195]opyright 1995-[195]ompute
  23. 4345 [153][163]11)"atnll (NULL)ights (NULL)eserved
  24. 4350 printtab(45)" [205]ax [198]ile [211]ize is"int((re-ms)/256)"[157] blocks "
  25. 4355 print" [197]nter [198]ilename or [210]eturn [193]lone to [209]uit
  26. 4395 [142]
  27. 4500 [143]"tantantanget file name
  28. 4525 fd=0:printtab(16);:x$="[198]ile:":x=16:gosub 9000:nm$=x$:return
  29. 6000 rem"[192][192][192]get checksum
  30. 6010 [151]2,[165]l(ms):[151]3,[165]h(ms)
  31. 6015 [151]4,[165]l(me):[151]5,[165]h(me)
  32. 6050 [141]63999:[158]x
  33. 6060 ch[178][194](780)[170]256[172][194](781)
  34. 6065 [153][163]0)"onlenhecksum:"ch:[142]
  35. 6800 :[143]"tantantanload
  36. 6830 ms=fnd(55):rem reset to just behind basic
  37. 6920 y=678:x$=nm$
  38. 6922 fori=1tolen(x$):pokey+i,asc(mid$(x$,i,1)):next
  39. 6925 poke781,167:poke782,2:poke780,len(x$):sys65469
  40. 6930 poke780,1:poke781,8:poke782,0:sys65466
  41. 6940 poke780,0:poke781,fnl(ms):poke782,fnh(ms):sys65493
  42. 6960 me=peek(781)+256*peek(782)
  43. 6970 lf=0:ef=peek(783)and1
  44. 6972 ifefthenprint" error loading! file not found [146]":me=ms+5
  45. 6990 return
  46. 9000 rem"[192][192][192]input text
  47. 9005 cu$[178]" cmd":[153]x$" "cu$;:p[178]0:[151]198,0:x$[178]""
  48. 9010 [151]204,0:[146]198,7:[151]204,1:[161]y$:y[178][198](y$):[139]y[178]13[167]9060
  49. 9020 [139]y[178]20[175]p[177]0[167]p[178]p[171]1:[153]y$cu$;:x$[178][200](x$,[195](x$)[171]1):[137]9010
  50. 9030 [139]p[177][178]x[167]9010
  51. 9040 [139]y$[179]" "[176]y$[177]"(NULL)"[176](y$[179]"atn"[175]y$[177]"_")[167]9010
  52. 9050 [153]" cmd";y$cu$;:x$[178]x$[170]y$:p[178]p[170]1:[137]9010
  53. 9060 [153]" ":x[178][195](x$):[142]
  54. 63999 x[178][194](61)[170]256[172][194](62)[170]30:[142]
  55.