home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18624 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.7 KB  |  54 lines

  1. Nntp-Posting-Host: hnoss.ifi.uio.no
  2. Newsgroups: comp.sys.mac.programmer
  3. Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!larsel
  4. From: larsel@ifi.uio.no (Lars Yngvar Ellingsen)
  5. Subject: HELP: Inline assembly in Think C
  6. Message-ID: <1992Nov19.014824.4747@ifi.uio.no>
  7. Keywords: assembly 
  8. Sender: larsel@ifi.uio.no (Lars Yngvar Ellingsen)
  9. Organization: Dept. of Informatics, University of Oslo, Norway
  10. References:  <BxxJ6A.KHw@mentor.cc.purdue.edu>
  11. Date: Thu, 19 Nov 1992 01:48:24 GMT
  12. Lines: 39
  13. Originator: larsel@hnoss.ifi.uio.no
  14.  
  15.  
  16. Yes, I know it sounds stupid, but I'm writing a flight simulator. In this
  17. flightsim I need some quick drawing routines. I had a friend write a small
  18. assembly routine on the amiga, but I have trouble with porting it to 
  19. think C 5.0.2's inline assembler. Here is a (very) brushed up version of the
  20. code:
  21. (The routine is supposed to write a row of pixels from position x,y with 
  22. one specific value on the screen in 8-bits color.)
  23. (I'm extremely inexperienced with both C and asm so forgive my stupid 
  24. blunders :)
  25.  
  26. main()
  27. {
  28.   GDHandle    theDevice;
  29.   unsigned char *color;
  30.   long          *address; 
  31.   short         x,y,*width;
  32.   unsigned int  color;
  33.    
  34.   theDevice = GetMainDevice();
  35.  
  36.   // do stuff; assign values to x, y, color and width
  37.   
  38.   &address = &(*(**(**theDevice).gdPMap).baseAddr)+
  39.              (long)y*SCREENWIDTH+(long)x;
  40.   asm {
  41.     @Main:   move.b    color,d1
  42.              move.w    width,d2
  43.              movea.l   address,a1
  44.     @Loop:   move.b    d1,(a1)+
  45.              dbra      d2,@Loop
  46.              rts         
  47.   }
  48. }
  49.  
  50. What am I doing wrong?
  51.  
  52. Yours sincerly,
  53. Lars // larsel@ifi.uio.no
  54.