;--------------------------- MainLoop.SUB --------------------------- sub MainLoop ;=================================================================== WHILE MainLoop = 0 DO CountLines := -1 call LineFeed return := 1 TextPosition := 9 $sentence := "" $return := "\r" $backspace := "\b" color 0, green ; make cursor green text 0,9,192,"~" ; character modified to be cursor ;-------------------------------------------------------------------- while return # 0 do getchar $letter length $letter, temp ; temp = 0 if NO letter pressed, temp = 1 if letter value $letter, val temp := temp * (val < 127) ; temp is 1 only if keypress is alpha/numeric compare $letter, $return, return compare $letter, $backspace, backspace if ButtonUsed = 1 or ButtonUsed > 3 then return := 0 ; set to zero so as to erase cursor and exit loop copy 2, x1,y1,x2,y2, 0, x,y ; draw button in down position pause 15 ; to keep mouse pointer from temporarily freezing while leftbutton = 1 do ; wait till button released endwhile y1 := y1 + offset y2 := y2 + offset offset := -13 endif if ButtonUsed = 1 then copy 2, x1, y1, x2, y2, 0, x,y ; draw button popping up endif if return = 0 then ; return was pressed color 0,white mode 0, draw rect 0, TextPosition,184, TextPosition + 5,192 ; erase cursor mode 0,overlay elsif backspace = 0 then ; backspace was pressed length $sentence, sentence if sentence = 0 then ; The sentence has length zero, so do nothing! else sentence := sentence - 1 TextPosition := TextPosition - 6 left $sentence, sentence, $sentence color 0,white mode 0,draw rect 0, TextPosition,184, TextPosition + 11,192 ; erase letter & cursor mode 0,overlay color 0,green text 0,TextPosition,192,"~" ; type cursor endif elsif TextPosition > 240 then ; outside text window elsif temp > 0 then ; accept the keypress $sentence := "@$sentence @$letter" ; add letter to sentence color 0,white mode 0, draw rect 0, TextPosition,184, TextPosition + 5,192 ; erase cursor color 0,green mode 0,overlay text 0,TextPosition,192,"@$letter ~" ; type letter and cursor TextPosition := TextPosition + 6 endif if ButtonUsed > 0 then ; blank any previous input typed before typing button contents mode 0,draw ; or overlay color 0,white rect 0, 9,185, 249,192 color 0,green call PrintText ; echo the button name to the text window $sentence := $tx return := 0 endif readbuttons ; check for mouse button presses between letters, and go there readbuttons empty ; in case further buttons were pressed while away if ButtonUsed = 9 then return := 0 endif endwhile ; end of input loop, ie. return = 0 ;-------------------------------------------------------------------- if ButtonUsed < 9 then ; ........................................... color 0, blue compare $sentence, "load", dummy if dummy = 0 then ButtonUsed := 4 ; so that player can click or type LOAD t \f t t t t t t t t t t Please Wait for Loading x1 := 137 y1 := 151 x2 := 197 y2 := 163 x := 259 y := 151 Screenmode text ; switch to black text screen with white writing endif compare $sentence, "save", dummy if dummy = 0 then ButtonUsed := 5 ; so that player can click or type SAVE t \f t t t t t t t t t t Please Wait for Saving x1 := 198 y1 := 151 x2 := 258 y2 := 163 x := 259 y := 169 unload screen 24 Screenmode text ; switch to black text screen with white writing endif compare $sentence, "quit", temp if temp = 0 then MainLoop := 1 else ghost "@$sentence" turn if error > 0 then if ButtonUsed > 3 then $tx := "SAVE GAME ERROR: play at your own risk." else $tx := $lasterror endif call print endif endif if ButtonUsed > 3 and ButtonUsed < 9 then t \f show screen 0 ScreenMode graphics create screen 24, 55, 78, 5, lores ; for ladder overlays mask 24 mode 0, draw copy 2, x1, y1, x2, y2, 0, x,y ; draw button popping up (load/save) load screen 1, "ram:loc@RoomNumber" ; try to load it, see if it's there if error > 0 then ; if it's not then $device := "Cannibal:video/" ; set path name to video/ else ; otherwise $device := "ram:" ; set path name to ram: endif endif endif ; ............................................................. ButtonUsed := 0 ENDWHILE ; end of main loop ;==================================================================== DOS "delete >NIL: ram:loc#?" ; clear ram: after game ends quit endsub ;--------------------------------------------------------------------