inflate.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * =====================================================================================
  3. *
  4. * ________ .__ __ ________ ____ ________
  5. * \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
  6. * / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
  7. * / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
  8. * \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
  9. * \__> \/ \/ \/ \/ \/
  10. *
  11. * www.optixx.org
  12. *
  13. *
  14. * Version: 1.0
  15. * Created: 09/22/2009
  16. * Author: jannis@harderweb.de
  17. *
  18. * =====================================================================================
  19. */
  20. #include <string.h>
  21. #include <stdio.h>
  22. #include "neginf/neginf.h"
  23. #include "inflate.h"
  24. char inflate_done = 0;
  25. char *mem;
  26. int addr = 0;
  27. void inflate_init()
  28. {
  29. neginf_init(0);
  30. mem = (char*)malloc(2<<16);
  31. addr = 0;
  32. }
  33. void inflate_flush()
  34. {
  35. FILE *file;
  36. file = fopen("out.smc","w");
  37. fwrite(mem,2<<16,1,file);
  38. fclose(file);
  39. }
  40. void neginf_cb_completed()
  41. {
  42. inflate_done = 1;
  43. }
  44. void neginf_cb_seq_byte(nbyte byte)
  45. {
  46. mem[addr] = byte;
  47. addr++;
  48. }
  49. void neginf_cb_copy(nsize from, nsize to, nint length)
  50. {
  51. int i;
  52. printf("neginf_cb_copy from=0x%06x to=0x%06x len=%i\n",from, to, length);
  53. for (i=0; i<length;i++)
  54. mem[to+i] = mem[from+i];
  55. addr = to + length;
  56. }