;--------------------------- GetDrop.SUB ---------------------------- sub Get $tx := "Use the mouse to drag it over to the" call print $tx := "inventory window. If there are more" call print $tx := "than 5 objects at this location, you" call print $tx := "will have to press the up and down" call print $tx := "arrows to scroll the objects." call print endsub ;-------------------------------------------------------------------- sub Drop $tx := "Use the mouse to drag it out of the" call print $tx := "inventory window, and into the location" call print $tx := "window." call print endsub ;-------------------------------------------------------------------- sub GetObject Pic := ( MouseY - 21 ) / 18 ; returns value 0-4 for picture chosen ChosenPic := Pic + SBPosition ; returns value 0 - (MaxMov - 1) (0-18) pixel 2, ChosenPic,2,ObjNum ; read object number of chosen pic into ObjNum IF ObjNum > 0 THEN ; if the spot clicked on is not empty then mode 2, draw color 2, white rect 2, 285,183, 299,199 ; copy white to background in hidden buffer OldX := 235 ; old x value from where object is coming OldY := 21 + 18 * Pic ; old y value from where object is coming temp := OldY NewX := MouseX - 8 ; value set early, in case of a really quick click NewY := MouseY - 9 ; that bypasses the while loop below pause 15 ; to keep blitter happy and avoid temporary freeze ups While Leftbutton = 1 do ; while button is held down, move object if OldX # MouseX - 8 or OldY # MouseY - 9 then ; if mouse moved NewX := MouseX - 8 ; offset by -8 so you are grabbing the obj center NewY := MouseY - 9 ; offset by -9 so you are grabbing the obj center mode 0, draw copy 2, 285,183, 299,199, 0, OldX,OldY ; restore old background copy 0, NewX, NewY, NewX + 14, NewY + 16, 2, 285,183 ; copy bkgd mode 0, overlay copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 0, NewX, NewY OldX := NewX OldY := NewY endif endwhile mode 0, draw copy 2, 285,183, 299,199, 0, oldX,oldY ; restore old background mode 0, overlay x1 := NewX - 235 ; x distance that object was moved x1 := (x1 > 0) * 2 * x1 - x1 ; absolute value of x1 y1 := NewY - temp ; y distance that object was moved y1 := (y1 > 0) * 2 * y1 - y1 ; absolute value of y1 if x1 < 8 and y1 < 8 then; moved very little, so player wanted to EXAMINE copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 0, 235,temp ; put it back ObjName ObjNum, $temp ; put the name of ObjNum in $temp so we can... $tx := "examine the @$temp" ButtonUsed := 2 elsif NewX > 257 and NewY < 45 then ; inv window if items < 7 then ; if there's room in inventory, add the object temp1 := 0 ; 3 spaces across inventory window temp2 := 0 ; 2 spaced down inventory window while temp2 < 2 while temp1 < 3 pixel 2, temp1, temp2, Slot ; see if inventory slot is taken if Slot = 0 then ; empty slot found x := temp1 ; remember the location of the empty slot y := temp2 ; remember the location of the empty slot temp1 := 3 ; force the loop to exit temp2 := 2 ; force the loop to exit endif temp1 := temp1 + 1 endwhile temp2 := temp2 + 1 temp1 := 0 endwhile copy 2,ObjNum * 15 - 15,183,ObjNum * 15 - 1,199,0,x * 16 + 266,y * 18 + 17 ; put object ObjNum in inventory window mode 2, draw color 2, ObjNum ; set value, before writing to array rect 2, x, y, x, y; write ObjNum to array grab ObjNum if ObjNum = 1 then ; if grab ladder we must also move the BIG ladder if RoomNumber = 6 then ; by shack directions meadow, n s e w call ReDrawScreen ; so as to make the ladder disappear elsif RoomNumber = 7 then ; by tree directions top_of_the_cliff, w call ReDrawScreen elsif RoomNumber = 9 then ; by upright boulder directions by_the_boulder, n call ReDrawScreen elsif RoomNumber = 11 then directions by_the_boulder, n e call ReDrawScreen elsif RoomNumber = 13 then ; by hole in cave directions in_the_cave, w call ReDrawScreen endif endif mode 2, draw copy 2, ChosenPic + 1,2,MaxMov,2, 2, ChosenPic,2 ; slide up array mode 23, draw copy 23, 0,ChosenPic * 18 + 18, 14,360, 23, 0,ChosenPic * 18 ; slide up obj ObjTotal := ObjTotal - 1 call DisplaySB ; show new scrollbar with object missing call CannibalsArrive ; increment timer and check for cannibals else ; if over inventory limit, put back in scrollbar copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 0, 235,temp ; put object ObjNum back in scrollbar at location pic endif else ; if object released outside inventory window, put in scrollbar copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 0, 235,temp ; put object ObjNum back in scrollbar at location pic endif ENDIF endsub ;-------------------------------------------------------------------- sub DropObject x := ( MouseX - 266 ) / 16 ; returns value 0-2 y := ( MouseY - 17 ) / 18 ; returns value 0-1 pixel 2, x,y,ObjNum ; read object number of chosen pic into ObjNum IF ObjNum > 0 THEN ; if the spot clicked on is not empty then mode 2, draw color 2, white rect 2, 285,183, 299,199 ; copy white to background in hidden buffer OldX := 266 + 16 * x ; old x value from where object is coming OldY := 17 + 18 * y ; old y value from where object is coming temp1 := OldX temp2 := OldY NewX := MouseX - 8 ; read these values early, in case player clicks so NewY := MouseY - 9 ; fast that the following while loop is skipped pause 15 ; so that temporary freeze ups are avoided While Leftbutton = 1 do ; while button is held down, move object if OldX # MouseX - 8 or OldY # MouseY - 9 then ; if mouse moved NewX := MouseX - 8 ; offset by -8 so you are grabbing the obj center NewY := MouseY - 9 ; offset by -9 so you are grabbing the obj center mode 0, draw copy 2, 285,183, 299,199, 0, OldX,OldY ; restore old background copy 0, NewX, NewY, NewX + 14, NewY + 16, 2, 285,183 ; copy new background mode 0, overlay copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 0, NewX, NewY OldX := NewX OldY := NewY endif endwhile mode 0, draw copy 2, 285,183, 299,199, 0, oldX,oldY ; restore old background before... mode 0, overlay if NewX < 260 then ; put object in scrollbar mode 2, draw color 2, 0 rect 2, x, y, x, y; write zero (black) (empty) to array drop ObjNum if ObjNum = 1 then ; if dropped ladder if RoomNumber = 6 then directions meadow, n s e w u link meadow, u, top_of_the_shack call ReDrawScreen elsif RoomNumber = 7 then directions top_of_the_cliff, u w link top_of_the_cliff, u, in_the_tree call ReDrawScreen elsif RoomNumber = 9 then directions by_the_boulder, n u link by_the_boulder, u, top_of_the_boulder call ReDrawScreen elsif RoomNumber = 11 then directions by_the_boulder, n e u link by_the_boulder, u, top_of_the_boulder call ReDrawScreen elsif RoomNumber = 13 then directions in_the_cave, w u link in_the_cave, u, rock_room call ReDrawScreen endif endif call AddObject call CannibalsArrive ; increment timer and check for cannibals else ; put object back in inventory copy 2,ObjNum * 15 - 15,183,ObjNum * 15 - 1,199,0,temp1,temp2 temp1 := NewX - temp1 ; x distance mouse was moved temp1 := (temp1 > 0) * 2 * temp1 - temp1 ; absolute value of temp1 temp2 := NewY - temp2 ; y distance mouse was moved temp2 := (temp2 > 0) * 2 * temp2 - temp2 ; absolute value of temp2 if temp1 < 8 and temp2 < 8 then; moved very little, so assume EXAMINE ObjName ObjNum, $temp ; store name of ObjNum in $temp so we can send msg $tx := "examine the @$temp" ButtonUsed := 2 endif endif ENDIF endsub ;-------------------------------------------------------------------- sub ReDrawScrollBar mode 23, draw color 23, white rect 23, 0,0, 14, 360 ; blank out previous contents of scroll bar ObjNum := 1 ; start with object number 1 (ladder) ObjTotal := 0 ; start with picture position 0, top of scrollbar while ObjNum < MaxMov + 1 do ; loop through all 19 objects, put in scrollbar if ObjNum in thisroom then mode 23, overlay copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 23, 0, ObjTotal * 18 mode 2, draw ; save the ObjNum in an array, so later color 2, ObjNum ; when the player clicks on an object in rect 2, ObjTotal,2, ObjTotal,2 ; the scrollbar, we will know which one ObjTotal := ObjTotal + 1 ; it is. Works as long as ObjNum < 32 endif color 2, 0 rect 2, ObjTotal,2, MaxMov,2 ; zero out rest of array ObjNum := ObjNum + 1 endwhile ; example: 7 objects, stored in 0-6, ObjTotal = 7 call DisplaySB endsub ;-------------------------------------------------------------------- sub DisplaySB if SBPosition > ObjTotal - 5 then ; makes sure scroll bar is scrolled SBPosition := ObjTotal - 5 ; to show as many objects as possible endif if SBPosition < 0 then SBPosition := 0 endif call DrawArrows ; puts scrollbar arrows on screen if needed mode 0, draw ; draw scroll bar on screen copy 23, 0, SBPosition * 18, 14, SBPosition * 18 + 89, 0, 235, 21 endsub ;-------------------------------------------------------------------- sub AddObject mode 2, draw copy 2, 0,2,ObjTotal,2, 2, 1,2 ; slide array down one color 2, ObjNum rect 2, 0,2,0,2 ; add object to front of list ObjTotal := ObjTotal + 1 mode 23, draw copy 23, 0,0, 14, 342, 23, 0, 18 ; slide down objects on scrollbar color 23, white rect 23, 0, 0, 14, 17 mode 23, overlay copy 2, ObjNum * 15 - 15,183, ObjNum * 15 - 1,199, 23, 0, 0 SBPosition := 0 call DrawArrows ; puts scrollbar arrows on screen if needed mode 0, draw ; draw scroll bar on screen copy 23, 0, SBPosition * 18, 14, SBPosition * 18 + 89, 0, 235, 21 endsub ;-------------------------------------------------------------------- sub ClickUpArrow while leftbutton ; move scrollbar as long as the mouse button is depressed if UpArrowActive then mode 0, draw copy 2, 275, 139, 287, 149, 0, 236, 6 ; show up arrow depressed pause 5 ; to keep keep mouse pointer from freezing temp := 0 while temp < 18 do temp := temp + 1 copy 23,0,SBPosition * 18 - temp,14,SBPosition * 18 + 89 - temp,0,235, 21 endwhile SBPosition := SBPosition - 1 call DrawArrows ; draws arrows if appropriate, blanks it otherwise endif endwhile readbuttons empty endsub ;-------------------------------------------------------------------- sub ClickDownArrow while leftbutton ; keep scrolling while mouse button depressed if DownArrowActive then mode 0, draw copy 2, 260, 139, 272, 149, 0, 236, 114 ; show down arrow depressed pause 5 ; to keep keep mouse pointer from freezing SBPosition := SBPosition + 1 temp := 18 while temp > 0 do temp := temp - 1 copy 23,0,SBPosition * 18 - temp,14,SBPosition * 18 + 89 - temp,0,235, 21 endwhile call DrawArrows ; draws arrows if appropriate, blanks it otherwise endif endwhile readbuttons empty endsub ;-------------------------------------------------------------------- sub DrawArrows DownArrowActive := 0 UpArrowActive := 0 mode 0, draw ; in case we need to draw arrows on scrollbar if SBPosition + SBSize < ObjTotal then ; more objects are below DownArrowActive := 1 copy 2, 260, 126, 272, 136, 0, 236, 114 ; show down arrow normal else copy 2, 290, 126, 302, 136, 0, 236, 114 ; blank down arrow endif if SBPosition > 0 then ; more objects are above UpArrowActive := 1 copy 2, 275, 126, 287, 136, 0, 236, 6 ; show up arrow normal else copy 2, 290, 126, 302, 136, 0, 236, 6 ; blank up arrow endif endsub ;-------------------------------------------------------------------- sub DestroyObject ; used for EAT SNICKER or BREAK BOTTLE temp1 := 0 ; 3 spaces across inventory window temp2 := 0 ; 2 spaced down inventory window while temp2 < 2 while temp1 < 3 pixel 2, temp1, temp2, Slot ; check contents of each slot if Slot = ObjNum then ; object has been found x := temp1 y := temp2 temp1 := 3 temp2 := 2 endif temp1 := temp1 + 1 endwhile temp2 := temp2 + 1 temp1 := 0 endwhile mode 2, draw color 2, 0 rect 2, x,y, x,y ; zero (black) out the inventory array element mode 0, draw ; blank out object in inventory window by painting color 0, white ; over it with a white rectangle rect 0, 266 + 16 * x, 17 + 18 * y, 280 + 16 * x, 33 + 18 * y drop ObjNum placeobj ObjNum, unused endsub ;--------------------------------------------------------------------