home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 269.lha / ShamView / sham.sample.code < prev    next >
Text File  |  1989-08-03  |  2KB  |  69 lines

  1. This is Modula-2 code that could be used to display a Sliced Ham picture. At
  2. this stage, I'll assume you've read and displayed the file like a normal HAM
  3. picture. I'll also assume that you've moved the file pointer to point to the
  4. SHAM chunk's first byte of data (which follows the SHAM identifier, chunk
  5. size, and a version word (currently 0). Take a look at a SHAM picture before
  6. you start. Each word is in the form 0rgb.
  7.  
  8. I've stretched the code out a bit to try to make it obvious to people
  9. unfamiliar with Modula-2. Clever coders can make this code much smaller and
  10. more efficient.
  11.  
  12. I hope we see assembly and C code posted soon.
  13.  
  14.  
  15.  (* Let's move the palette into an array for clarity *)
  16.  
  17.  FOR i := 0 TO 199 DO
  18.   FOR j := 0 TO 15 DO
  19.    dummy := Read(f,ADR(k),2);
  20.    rPalette[i,j] := INTEGER(k) DIV 256;
  21.    gPalette[i,j] := INTEGER(k) DIV 16 MOD 16;
  22.    bPalette[i,j] := INTEGER(k) MOD 16;
  23.   END;
  24.  END;
  25.  
  26.  (* first handle top line *)
  27.  
  28.  SetRGB4(vp,0,0,0,0);
  29.  FOR i := 1 TO 15 DO
  30.   SetRGB4(vp,i,rPalette[0,i],gPalette[0,i],bPalette[0,i]);
  31.  END;  
  32.  
  33.  (* now the rest *)
  34.  
  35.  ucop := AllocMem(TSIZE(UCopList),MemReqSet{MemChip,MemClear});
  36.  FOR i := 1 TO 199 DO
  37.   CWAIT(ucop,i,0);
  38.   FOR j := 1 TO 15 DO
  39.    CMOVE(ucop,ADR(custom^.color[j]),rPalette[i,j]*256+
  40.          gPalette[i,j]*16+bPalette[i,j]);
  41.   END;
  42.  END;
  43.  CEND(ucop);
  44.  
  45.  (* Now tell the Amiga *)
  46.  
  47.  WITH vp^ DO
  48.   dspins := DspIns;
  49.   sprins := SprIns;
  50.   clrins := ClrIns;
  51.  END;
  52.  vp^.UCopIns := ucop;
  53.  RethinkDisplay();
  54.  
  55.  (* Time Waster *)
  56.  
  57.  WHILE GetMsg(window^.UserPort)=NIL DO END;
  58.  
  59.  (* Clean up *)
  60.  
  61.  FreeVPortCopLists(vp);
  62.  RemakeDisplay();
  63.  CloseWindow(window);
  64.  CloseScreen(scr);
  65.  
  66. BEGIN
  67.  BuildScreen();
  68. END vSup.
  69.