home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / E / Screens / Scroll&Sprite.e < prev    next >
Encoding:
Text File  |  1997-01-29  |  3.1 KB  |  98 lines

  1. /* Horizontal Scroll 640
  2. ** ---------------------
  3. ** This opens an extra wide screen of 640x256 pixels, and hardware scrolls
  4. ** left and right.  This is *totally* inadequate for platformers, shoot'em-ups
  5. ** etc because the picture size takes up huge amounts of memory.  However for
  6. ** games like Skidmarks, Lemmings, Monkey Island, etc, such large screens can
  7. ** be a necessity.
  8. */
  9.  
  10. MODULE 'games','games/games','exec/memory'
  11.  
  12. PROC main()
  13.    DEF screen:PTR TO gamescreen, palette:PTR TO INT, direction=1:LONG,
  14.        sparkie:PTR TO sprite, zbxy:LONG, timer:LONG, loadpic:PTR TO picture
  15.  
  16.    palette := [
  17.     $000,$400,$501,$501,$601,$701,$701,$801,
  18.     $901,$A01,$B02,$432,$CC0,$F00,$211,$880,
  19.     $1C2,$050,$B0B,$606,$F20,$910,$BBB,$FFF,
  20.     $0BF,$068,$568,$9BF,$FF0,$EE0,$BA0,$540
  21.    ]:INT;
  22.  
  23.    sparkie := [
  24.     SPV1,0,         -> Version number
  25.     0,              -> Bank Number 0
  26.     0,              -> Ptr to graphic
  27.     150,150,        -> Beginning X/Y positions
  28.     0,              -> Current frame
  29.     16,21,          -> Width, Height
  30.     16,             -> Amt of colours
  31.     16,             -> Colour start in palette
  32.     2,              -> Amt of planes
  33.     LORES,          -> Resolution attributes
  34.     0,              -> Position in relation to playfields
  35.     XLONG           -> Special attributes.
  36.    ]:sprite;
  37.  
  38.    loadpic := [
  39.     PCV1,0,            -> Version header.
  40.     0,                 -> Destination.
  41.     640,0,256,         -> Width, Height.
  42.     4,                 -> Amount of Planes.
  43.     0,                 -> Amount of colours.
  44.     0,                 -> Palette (remap).
  45.     LORES OR COL12BIT, -> Screen mode.
  46.     ILBM,              -> Destination.
  47.     0,                 -> Parameters.
  48.     'GAMESLIB:data/IFF.Pic640x256'
  49.    ]:picture;
  50.  
  51.    IF gmsbase := OpenLibrary('games.library',0)
  52.     SetUserPrefs(0)
  53.     IF (screen := AddScreen([TAGS,0,
  54.         GSA_PALETTE,palette,
  55.         GSA_SCRWIDTH,320,
  56.         GSA_SCRHEIGHT,256,
  57.         GSA_PICWIDTH,640,
  58.         GSA_AMTCOLOURS,32,
  59.         GSA_PLANES,4,
  60.         GSA_SCRATTRIB,HSCROLL OR SPRITES OR NOSCRBDR,
  61.         GSA_SCRMODE,LORES OR COL12BIT,
  62.         GSA_SCRTYPE,ILBM,
  63.         TAGEND]))
  64.  
  65.      loadpic.data := screen.memptr1;
  66.      IF (LoadPic(loadpic) = ERR_OK)
  67.       sparkie.data := SmartLoad('GAMESLIB:data/sparkie.raw',0,MEMF_CHIP)
  68.       IF (sparkie.data)
  69.        ShowScreen(screen)
  70.        InitSprite(screen,sparkie)
  71.        UpdateSprite(screen,sparkie)
  72.        zbxy := ReadMouse(JPORT1)
  73.  
  74.        REPEAT
  75.          zbxy := ReadMouse(JPORT1)
  76.          IF (timer++ AND $1)
  77.             IF (sparkie.frame = 5) THEN sparkie.frame := 0 ELSE sparkie.frame := sparkie.frame+1
  78.          ENDIF
  79.          sparkie.xpos := sparkie.xpos+getZBXYx(zbxy)
  80.          sparkie.ypos := sparkie.ypos+getZBXYy(zbxy)
  81.          IF (screen.picxoffset = 320) THEN direction := -2
  82.          IF (screen.picxoffset = 0) THEN direction := 2
  83.          screen.picxoffset := screen.picxoffset+direction
  84.          MovePicture(screen)
  85.          WaitSVBL()
  86.          UpdateSprite(screen,sparkie)
  87.        UNTIL !(zbxy AND MB_LMB)
  88.  
  89.       FreeMemBlock(sparkie.data);
  90.       ENDIF
  91.      ENDIF
  92.      DeleteScreen(screen)        
  93.     ENDIF
  94.    CloseLibrary(gmsbase)
  95.    ENDIF
  96. ENDPROC
  97.  
  98.