home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 42 / af042b.adf / Extras.lha / Map_Editor.AMOS / Map_Editor.amosSourceCode < prev    next >
AMOS Source Code  |  1992-02-21  |  22KB  |  892 lines

  1. Rem ---------------------------------------------------------  
  2. Rem -              TAME (Total Amiga Map Editor)            -
  3. Rem -                                                       -
  4. Rem -             Programmed by Aaron Fothergill            -  
  5. Rem -                (c) Mandarin / Jawx 1990               -
  6. Rem ---------------------------------------------------------
  7. Rem
  8. Rem                     READ THIS FIRST! 
  9. Rem
  10. Rem         *** WARNING! Unexpanded A500 users *** 
  11. Rem  
  12. Rem Memory is at a premium on 1/2 meg machines and you should thus 
  13. Rem realise that only so much data can fit into such machines. 
  14. Rem
  15. Rem * For an Example of how to use the Map_Editor, load the compacted
  16. Rem   screen "MFTiles.Abk" from the Magic Forest folder on the AMOS_DATA 
  17. Rem   disc. The Map files can then be loaded in and will show how Aaron
  18. Rem   designed each level. 
  19. Rem
  20. Rem This map editor requires a lot of work space so to avoid the 
  21. Rem 'out of memory' errors during the running of TOME, try to respect
  22. Rem the following points:
  23. Rem
  24. Rem * Don't design your icons in 32 colour mode. The vast size of such 
  25. Rem   a screen simply eats a massive chunk out of memory. The picture file 
  26. Rem   'Amospic.Iff' on the AMOS_DATA: disc is a prime example. This file 
  27. Rem   cannot be loaded and used with TOME on such a small system.  
  28. Rem
  29. Rem * Make sure TOME is the first thing you run on the machine. The Amiga
  30. Rem   breaks memory up as it is asked for. Read page 52 of your AMOS 
  31. Rem   manual for more details. 
  32. Rem  
  33. Rem * MXLN states the amount of tile strips that will be cut out of the
  34. Rem   loaded IFF picture. Reduce it or enlarge to your own needs.
  35. MXLN=5
  36. Dim C(7),C2(7),C3(7),LINE$(5),BUTTON$(3)
  37. Screen Close 0
  38. If Length(2)>0
  39.    Erase 2
  40. End If 
  41. TITLEBAR
  42. Auto View Off 
  43. Screen Open 1,320,90,8,Lowres
  44. Cls 
  45. Screen Display 1,,48,,90
  46. Screen To Front 2
  47. Screen 1
  48. MAKEICONS
  49. Curs Off : Flash Off 
  50. Get Palette(2)
  51. Screen Copy 2,0,0,320,90 To 1,0,0
  52. Screen Close 2
  53. Auto View On 
  54. Paper 0 : Pen 1
  55. Menu$(1)="(IC 1)"
  56. Menu$(1,1)=" About..."," Tame.   "
  57. Menu$(2)="FILE "
  58. Menu$(2,1)=" Load Tiles"
  59. Menu$(2,2)=" Load Map  "
  60. Menu$(2,3)=" Save Map  "
  61. Menu$(2,4)=" Quit      "
  62. Menu$(4)="Change "
  63. Menu$(4,1)=" Tile Size"
  64. Menu$(4,2)=" Map Size "
  65. Menu$(4,1,1)="(IC 2:Locate 16,0)16x16" : Menu$(4,1,2)="(IC 3:Locate 32,0)32x16"
  66. Menu$(4,1,3)="(IC 4:Locate 16,0)16x32" : Menu$(4,1,4)="(IC 5:Locate 32,0)32x32"
  67. Set Menu(4,1,1) To -96,-16
  68. Set Menu(4,1,2) To 68,0
  69. Set Menu(4,1,3) To -68,20
  70. Set Menu(4,1,4) To 68,0
  71. Menu$(5)="Tools "
  72. Menu$(5,1)=" Draw     "
  73. Menu$(5,2)=" Do Box   "
  74. Menu$(5,3)=" Clear Map"
  75. Menu$(5,4)=" Pick Tile"
  76. Menu$(3)="Block "
  77. Menu$(3,1)=" Cut Block  "
  78. Menu$(3,2)=" Paste Block"
  79. Rem
  80. Rem xs(),ys() arrays hold the 4 different X and Y tile sizes 
  81. Rem blk(x,y) holds cut/paste block data up to x by y tiles 
  82. Rem
  83. Dim XS(3),YS(3),BLK(31,31)
  84. For A=0 To 3 : Read XS(A),YS(A) : Next A
  85. Data 16,16,32,16,16,32,32,32
  86. Rem
  87. Rem Screen 0 is used in this program to display the map
  88. Rem Screen 1 is set up in medium res to display co-ordinates and to handle 
  89. Rem the menus
  90. Rem Screen 2 contains the tiles stored as a screen 
  91. Rem
  92. Auto View Off 
  93. Screen Open 0,320,194,16,Lowres
  94. Curs Off : Flash Off 
  95. Screen Display 0,,77,,194
  96. Rem load in the tile screen (2) here 
  97. Rem the tile screen is also used as the updater screen 
  98. XSIZE=32 : YSIZE=32
  99. SCW=320 : SCH=192
  100. Show 
  101. Gosub LDTILES
  102. Hide 
  103. Screen To Back 2
  104. Screen 0
  105. Hide On 
  106. Get Palette(2)
  107. Wait Vbl 
  108. Screen To Front 0
  109. Screen 0
  110. Curs Off : Flash Off 
  111. If Length(6)=0
  112.    Rem clear the map to tile 0 the hard way ! 
  113.    Reserve As Work 6,260
  114.    A=0
  115.    Repeat 
  116.       Poke Start(6)+A*4,0
  117.       Inc A
  118.    Until A>243
  119. End If 
  120. Rem
  121. Rem the first 2 words of a map give the X & Y size of the map (In Tiles) 
  122. Doke Start(6),20 : Doke Start(6)+2,12
  123. TAMEVIEW[0,0,SCW/XSIZE,SCH/YSIZE,XSIZE,YSIZE]
  124. Rem O.K Every THING IS NOW SET UP  
  125. Show On 
  126. Limit Mouse 
  127. Rem get the menus going !
  128. Screen 1
  129. Reserve Zone 4
  130. Set Zone 4,211,30 To 315,87
  131. On Menu Gosub ABOUT,FILE,BLKS,CHANGE,TLS
  132. On Menu On 
  133. MO=1
  134. Menu On 
  135. Screen 0
  136. Set Menu(1) To 0,18
  137. Menu Static 1
  138. Rem The variable UTILE contains the tile number currently in use 
  139. UTILE=0
  140. Rem Whenever NM is set to anything but zero, the map will be re-drawn
  141. NM=1
  142. Auto View On 
  143. CLRTXT
  144. Screen 1 : Limit Mouse 
  145. Do 
  146.    Rem check for mouse click on map 
  147.    Rem menu will only work if mouse is at the top of the screen 
  148.    If Y Screen(Y Mouse)<=0 and MO=0 Then SETSCRN[1] : Menu On : MO=1
  149.    If Y Screen(Y Mouse)>83 and MO=1 Then Menu Off : SETSCRN[0] : MO=0
  150.    If Mouse Key=1 and Screen=0 Then If MDE=0 Then Gosub FXTILE Else Gosub FXBX
  151.    If Mouse Key=2 and Screen=0 Then PICKTILE : NM=1
  152.    Rem If nm is set then update map 
  153.    If NM=1 Then SC=Screen : DRWSCRN[0] : NM=0 : TAMEMAP[2,SCX,SCY] : Screen Copy 2 To 0 : DRWSCRN[1] : UPDATA : SETSCRN[SC]
  154.    A$=Inkey$
  155.    Rem Joystick and arrow key scroll controls for map 
  156.    If(Jleft(1) or Asc(A$)=29) and SCX>0 Then Dec SCX : NM=1
  157.    If(Jright(1) or Asc(A$)=28) and SCX+320/XSIZE<MAPX Then Inc SCX : NM=1
  158.    If(Jup(1) or Asc(A$)=30) and SCY>0 Then Dec SCY : NM=1
  159.    If(Jdown(1) or Asc(A$)=31) and SCY+192/YSIZE<MAPY Then Inc SCY : NM=1
  160.    Rem So does dragging map area box
  161.    If Mouse Key=1 and Screen=1
  162.       Gosub CHECKAREABOX
  163.    End If 
  164. Loop 
  165. Rem This procedure will put the screen S into the front, and set it as 
  166. Rem the logical screen, it will also reset the mouse limits to that screen 
  167. CHECKAREABOX:
  168. Z=Mouse Zone
  169. If Z=4
  170.    Rem box x,y =104x57
  171.    T=0
  172.    While Mouse Key<>0
  173.       SCXO=SCX
  174.       SCYO=SCY
  175.       SCX=((X Screen(X Mouse)-211)*MAPX)/104.0
  176.       SCY=((Y Screen(Y Mouse)-30)*MAPY)/57.0
  177.       SCX=Max(0,Min(MAPX-SCW/XSIZE,SCX))
  178.       SCY=Max(0,Min(MAPY-SCH/YSIZE,SCY))
  179.       While Mouse Key<>0 and T<100
  180.          Inc T
  181.       Wend 
  182.       Ink 1
  183.       If SCXO<>SCX or SCYO<>SCY
  184.          X1=(SCXO*104)/MAPX
  185.          Y1=(SCYO*57)/MAPY
  186.          X2=X1+(SCW/XSIZE*104)/MAPX
  187.          Y2=Y1+(SCH/YSIZE*57)/MAPY
  188.          Bar 211+X1,30+Y1 To 211+X2,30+Y2
  189.          X1=(SCX*104)/MAPX
  190.          Y1=(SCY*57)/MAPY
  191.          X2=X1+(SCW/XSIZE*104)/MAPX
  192.          Y2=Y1+(SCH/YSIZE*57)/MAPY
  193.          Ink 4
  194.          Bar 211+X1,30+Y1 To 211+X2,30+Y2
  195.       End If 
  196.    Wend 
  197.    NM=1
  198. End If 
  199. Return 
  200. Procedure DRWSCRN[S]
  201.    Y=Y Mouse
  202.    Screen S
  203.    Limit Mouse 
  204.    Y Mouse=Y
  205. End Proc
  206. Procedure SETSCRN[S]
  207.    Shared MDE
  208.    Y=Y Mouse
  209.    Screen S
  210.    Screen To Front S
  211.    Limit Mouse 
  212.    Y Mouse=Y
  213.    If S=0
  214.       Menu Off 
  215.       Hide On 
  216.       SETAUTO
  217.    Else 
  218.       Show On 
  219.       Amal Freeze 
  220.       Sprite Off 8
  221.    End If 
  222. End Proc
  223. Procedure SETAUTO
  224.    Shared MDE
  225.    SP=1
  226.    If MDE=1 or MDE=3
  227.       SP=2
  228.    End If 
  229.    If MDE=2 or MDE=4
  230.       SP=3
  231.    End If 
  232.    If MDE=5
  233.       SP=4
  234.    End If 
  235.    A$="AUtotest(Let R0=XM-X;Let R1=YM-Y;"
  236.    A$=A$+"If R0<>RX Jump Update"
  237.    A$=A$+"If R1<>RY Jump Update else eXit"
  238.    A$=A$+"Update: Let RX=R0; Let RY=R1; Direct M)"
  239.    A$=A$+"M: Move R0,R1,1 ; Jump M"
  240.    Sprite 8,X Mouse,Y Mouse,SP
  241.    Channel 0 To Sprite 8
  242.    Amal 0,A$
  243.    Amal On 
  244. End Proc
  245. Rem This procedure is to update the text in the data screen
  246. Rem done every time the screen scrolls 
  247. Procedure UPDATA
  248.    Shared SCW,SCH,MULX,MULY,FILE$,REZ$,NCOLS,UTILE,XSIZE,YSIZE,MAPX,MAPY,SCX,SCY
  249.    SCX=Max(0,Min(MAPX-SCW/XSIZE,SCX))
  250.    SCY=Max(0,Min(MAPY-SCH/YSIZE,SCY))
  251.    MULX=1 : MULY=1
  252.    TS=Screen
  253.    Screen To Back 2
  254.    Screen 2
  255.    Curs Off 
  256.    CLRTXT
  257.    Paper 6
  258.    Pen 1
  259.    Locate 22,4 : Print "MAP"
  260.    Pen 0
  261.    Locate 20,5 : Print "Tp Lft"
  262.    Locate 20,6 : Print "X:";Right$("  "+Str$(SCX),3)
  263.    Locate 20,7 : Print "Y:";Right$("  "+Str$(SCY),3)
  264.    Locate 21,8 : Print "Size"
  265.    Locate 20,9 : Print "X:"+Right$("  "+Str$(MAPX),3)
  266.    Locate 20,10 : Print "Y:"+Right$("  "+Str$(MAPY),3);
  267.    Ink 1
  268.    X=40-XSIZE/2
  269.    Y=58-YSIZE/2
  270.    Bar X,Y To XSIZE+X-1,YSIZE+Y-1
  271.    Bar 210,29 To 316,88
  272.    Ink 0
  273.    Box 210,29 To 316,88
  274.    X1=(SCX*104)/MAPX
  275.    Y1=(SCY*57)/MAPY
  276.    X2=X1+((320*MULX)/XSIZE*104)/MAPX
  277.    Y2=Y1+((192*MULY)/YSIZE*57)/MAPY
  278.    Ink 0,6
  279.    Ink 4
  280.    Bar 211+X1,30+Y1 To 211+X2,30+Y2
  281.    Put Block UTILE+1,X,Y
  282.    Paper 6 : Pen 1
  283.    Ink 1,6
  284.    Text 3,37,"Tile:"+Right$("  "+Str$(UTILE),3)
  285.    Ink 0,6 : Pen 0
  286.    Text X-(48-XSIZE)/4,Y+YSIZE+10,Right$(" "+Str$(XSIZE),2)+"x"+Right$(" "+Str$(YSIZE),2)
  287.    Paper 6 : Pen 1
  288.    Locate 11,5 : Print "SCREEN"
  289.    Pen 3
  290.    I=Instr(FILE$,":")+1
  291.    Locate 11,6 : Print Left$(Mid$(FILE$,I)+Space$(8),8)
  292.    Pen 0
  293.    Locate 11,7 : Print REZ$;" Rez"
  294.    Locate 11,8 : Print Right$("  "+Str$(NCOLS),2);" Cols"
  295.    Screen Copy 2,0,28,320,90 To 1,0,28
  296.    Screen TS
  297. End Proc
  298. Rem This routine waits for the mouse button to be released and then
  299. Rem re-does the menu bar 
  300. Procedure OMO
  301.    Shared NM
  302.    While Mouse Key<>0 : Wend : Rem this waits for mouse button off
  303.    On Menu On 
  304.    NM=1
  305. End Proc
  306. Rem Level 1 menu selection routines
  307. Rem About Menu 
  308. ABOUT:
  309. C=Choice(2)
  310. CREDITS
  311. OMO
  312. Return 
  313. Rem File Menu selector 
  314. FILE:
  315. C=Choice(2)
  316. On C Gosub LDTILES,LDMAP,SVMAP,QUIT
  317. OMO
  318. Return 
  319. Rem Change Menu Selector 
  320. CHANGE:
  321. C=Choice(2)
  322. If C=1
  323.    C2=Choice(3) : XSIZE=XS(C2-1) : YSIZE=YS(C2-1)
  324.    GTBLCKS : Cls 0 : TAMEVIEW[0,0,SCW/XSIZE,SCH/YSIZE,XSIZE,YSIZE]
  325.    MO=0
  326. End If 
  327. If C=2 Then Gosub SIZEMAP
  328. OMO
  329. Return 
  330. Rem blocks menu selector 
  331. BLKS:
  332. C=Choice(2)
  333. On C Gosub CUTBLK,PASTEBLK
  334. OMO
  335. Return 
  336. Rem Tools menu selector
  337. TLS:
  338. C=Choice(2)
  339. If C=1 Then MDE=0 : Rem draw mode
  340. If C=2 Then MDE=1 : Rem box mode (mde 2=bottom right)
  341. If C=3 Then Gosub CLRMAP
  342. If C=4 Then SETSCRN[0] : PICKTILE : SETSCRN[1]
  343. OMO
  344. Return 
  345. Rem level 2 menu routines (called from level 1)
  346. BLKMDE:
  347. If MDE=5
  348.    Gosub BLKSTICKER
  349. Else 
  350.    Gosub BLKCUTTER
  351. End If 
  352. Return 
  353. CUTBLK:
  354. Rem Cut a block of tiles from the map (controlled as draw box routine) 
  355. MDE=3
  356. Return 
  357. BLKCUTTER:
  358. Rem This routine is called from the box drawing routine (mde>0)
  359. If MDE=3
  360.    BTLX=X+SCX
  361.    BTLY=Y+SCY
  362.    MDE=4 : SETAUTO : While Mouse Key<>0 : Wend 
  363. Else 
  364.    MDE=5 : SETAUTO
  365.    BLKSX=X+SCX-BTLX
  366.    BLKSY=Y+SCY-BTLY
  367.    If BLKSX<=0
  368.       BLKSX=1
  369.    End If 
  370.    If BLKSY<=0
  371.       BLKSY=1
  372.    End If 
  373.    A=0 : Repeat 
  374.       B=0 : Repeat 
  375.          BLK(B,A)=Peek(Start(6)+4+BTLX+B+(BTLY+A)*MAPX)
  376.       Inc B : Until B>BLKSX
  377.    Inc A : Until A>BLKSY
  378. End If 
  379. While Mouse Key<>0 : Wend 
  380. Return 
  381. PASTEBLK:
  382. If BLKSX>0 and BLKSY>0
  383.    MDE=5
  384. End If 
  385. Return 
  386. BLKSTICKER:
  387. A=0 : Repeat 
  388.    B=0 : Repeat 
  389.       Poke Start(6)+4+((SCY+Y+A) mod MAPY)*MAPX+(SCX+X+B) mod MAPX,BLK(B,A)
  390.    Inc B : Until B>BLKSX
  391. Inc A : Until A>BLKSY
  392. NM=1
  393. Return 
  394. SVMAP:
  395. F$=Fsel$("*.MAP","","Save a TAME map")
  396. If F$<>""
  397.    Bsave F$,Start(6) To Start(6)+MAPX*MAPY+20
  398. End If 
  399. Return 
  400. LDMAP:
  401. F$=Fsel$("*.MAP","","Load a TAME map")
  402. If F$<>""
  403.    Open In 1,F$
  404.    L=Lof(1)
  405.    Close 1
  406.    Erase 6
  407.    Reserve As Work 6,L
  408.    Bload F$,Start(6)
  409.    MAPX=Deek(Start(6))
  410.    MAPY=Deek(Start(6)+2)
  411.    S6=Start(6)+MAPX*MAPY+4
  412.    XSIZE=Deek(S6) : YSIZE=Deek(S6+2)
  413.    TLX=Deek(S6+4) : TLY=Deek(S6+6)
  414.    TAMEW=Deek(S6+8) : TAMEH=Deek(S6+10)
  415.    BRX=Deek(S6+12) : BRY=Deek(S6+14)
  416.    TAMEVIEW[0,0,SCW/XSIZE,SCH/YSIZE,XSIZE,YSIZE]
  417. End If 
  418. Return 
  419. LDTILES:
  420. S=Screen
  421. FILE$=Fsel$("","","Select an IFF picture to load as tiles")
  422. If FILE$<>"" Then ICDONE=0 : Gosub LDPICCY : GTBLCKS : SETSCRN[S]
  423. Gosub GTREZ
  424. Screen Open 0,SCW,SCH,NCOLS,RZ
  425. Curs Off : Flash Off : Get Palette(2)
  426. Screen Display 0,,77,,SCH
  427. Screen To Front 1
  428. Return 
  429. LDPICCY:
  430. If Upper$(Right$(FILE$,4))=".ABK"
  431.    Load FILE$,5
  432.    A$="" : A=0 : Repeat : A$=A$+Chr$(Peek(Start(5)-8+A)) : Inc A : Until A=8
  433.    If A$="Pac.Pic."
  434.       Unpack 5 To 2
  435.    End If 
  436.    Erase 5
  437. Else 
  438.    Load Iff FILE$,2
  439. End If 
  440. Return 
  441. GTREZ:
  442. Screen To Front 2
  443. Screen 2
  444. A=Screen Base+72
  445. R=Deek(A)
  446. If Btst(15,R)
  447.    REZ$="Hi"
  448.    RZ=Hires
  449. Else 
  450.    REZ$="Low"
  451.    RZ=Lowres
  452. End If 
  453. NCOLS=Deek(A+24)
  454. SCW=Deek(A+4)
  455. SCH=Deek(A+6)
  456. Screen To Back 2
  457. Return 
  458. QUIT:
  459. While Mouse Key<>0 : Wend 
  460. LINE$(0)="Do you really"
  461. LINE$(1)="Want to Quit?"
  462. BUTTON$(0)="Byee"
  463. BUTTON$(1)="Cancel"
  464. ALERT[25,6,6,1,2,2]
  465. If Q=1
  466.    End 
  467. End If 
  468. Return 
  469. CLRMAP:
  470. LINE$(0)="What Tile do you want"
  471. LINE$(1)="the map cleared to ?"
  472. BUTTON$(0)="Tile 0"
  473. BUTTON$(2)="Cancel"
  474. BUTTON$(1)="Current"
  475. While Mouse Key<>0 : Wend 
  476. ALERT[37,6,6,1,3,2]
  477. If Q=1 or Q=2
  478.    T=UTILE : If Q=1
  479.       T=0
  480.    End If 
  481.    Menu Off 
  482.    Screen 0
  483.    Locate 0,10 : Paper 2 : Pen 0 : Centre "Clearing Map "
  484.    Locate 0,11 : Centre " Please Wait "
  485.    A=0 : Repeat 
  486.       B=0 : Repeat 
  487.          Poke Start(6)+4+A*MAPX+B,T
  488.          Inc B
  489.       Until B=MAPX
  490.       Inc A
  491.    Until A=MAPY
  492.    Screen 1
  493.    Menu On 
  494. End If 
  495. Return 
  496. SIZEMAP:
  497. Get Block 241,0,2,320,66
  498. Ink 1,4
  499. Set Paint 1
  500. Bar 10,2 To 116,66
  501. Bar 120,2 To 260,66
  502. Ink 4
  503. Box 12,4 To 114,64
  504. Box 122,4 To 258,64
  505. Ink 0
  506. Paper 1 : Pen 4
  507. Locate 17,5 : Print Zone$(Border$("O.K",1),2)
  508. Locate 24,5 : Print Zone$(Border$("Cancel",1),3)
  509. Set Paint 0
  510. Set Zone 1,12,4 To 113,63
  511. OK=0
  512. MX=MAPX : MY=MAPY : MXO=MX : MYO=MY
  513. While OK=0
  514.    Ink 0,1
  515.    Text 126,14,"Xsize:"+Right$("  "+Str$(MX),3)
  516.    Text 126,24,"Ysize:"+Right$("  "+Str$(MY),3)
  517.    Ink 1
  518.    Box 12,4 To 11+MXO/2,3+MYO/2
  519.    Ink 4
  520.    Box 12,4 To 114,64
  521.    Box 12,4 To 11+MX/2,3+MY/2
  522.    MXO=MX : MYO=MY
  523.    While Mouse Key=0 : Wend 
  524.    While Mouse Key<>0 : Wend 
  525.    Z=Mouse Zone
  526.    If Z=2
  527.       OK=1
  528.    End If 
  529.    If Z=1
  530.       MX=Max(SCW/XSIZE,2*(X Screen(X Mouse)-12))
  531.       MY=Max(SCH/YSIZE,2*(Y Screen(Y Mouse)-4))
  532.    End If 
  533.    If Z=3
  534.       OK=2
  535.    End If 
  536. Wend 
  537. Put Block 241,0,2
  538. Del Block 241
  539. If OK=1
  540.    MAPX=Deek(Start(6)) : MAPY=Deek(Start(6)+2)
  541.    S6=Start(6)+MAPX*MAPY+4
  542.    TLX=Deek(S6+4) : TLY=Deek(S6+6)
  543.    TAMEW=Deek(S6+8) : TAMEH=Deek(S6+10)
  544.    BRX=Deek(S6+12) : BRY=Deek(S6+14)
  545.    MAPX=MX : MAPY=MY
  546.    Erase 6
  547.    Reserve As Work 6,MAPX*MAPY+20
  548.    Doke Start(6),MAPX : Doke Start(6)+2,MAPY
  549.    S6=Start(6)+4+MAPX*MAPY
  550.    Doke S6,XSIZE : Doke S6+2,YSIZE
  551.    Doke S6+4,TLX : Doke S6+6,TLY
  552.    Doke S6+8,TAMEW : Doke S6+10,TAMEH
  553.    Doke S6+12,BRX : Doke S6+14,BRY
  554.    M$="TAME Map"
  555.    A=0 : Repeat : Poke Start(6)-8+A,Asc(Mid$(M$,A+1,1)) : Inc A : Until A=8
  556.    Curs Off 
  557.    Gosub CLRMAP
  558. End If 
  559. Return 
  560. FXTILE:
  561. X=X Screen(X Mouse)/XSIZE
  562. Y=Y Screen(Y Mouse)/YSIZE
  563. If(X+SCX<MAPX) and(Y+SCY<MAPY)
  564.    Poke Start(6)+4+(SCY+Y)*MAPX+(SCX+X),UTILE
  565.    TEMP=Screen
  566.    Screen 0
  567.    Cls 0,X*XSIZE,Y*YSIZE To(X+1)*XSIZE,(Y+1)*YSIZE
  568.    Put Block UTILE+1,X*XSIZE,Y*YSIZE
  569.    Screen TEMP
  570. End If 
  571. Return 
  572. FXBX:
  573. X=X Screen(X Mouse)/XSIZE
  574. Y=Y Screen(Y Mouse)/YSIZE
  575. If(X+SCX<MAPX) and(Y+SCY<MAPY)
  576.    If MDE>2
  577.       Gosub BLKMDE
  578.    Else 
  579.       Poke Start(6)+4+(SCY+Y)*MAPX+(SCX+X),UTILE
  580.       TEMP=Screen
  581.       Screen 0
  582.       Cls 0,X*XSIZE,Y*YSIZE To(X+1)*XSIZE,(Y+1)*YSIZE
  583.       Put Block UTILE+1,X*XSIZE,Y*YSIZE
  584.       Screen TEMP
  585.       If MDE=1
  586.          MDE=2 : BTLX=X+SCX : BTLY=Y+SCY : While Mouse Key<>0 : Wend 
  587.          SETAUTO
  588.       Else 
  589.          MDE=1
  590.          A=0 : Repeat 
  591.             B=0 : Repeat 
  592.                Poke Start(6)+4+(A+BTLY)*MAPX+(B+BTLX),UTILE
  593.             Inc B : Until B+BTLX>X+SCX
  594.          Inc A : Until A+BTLY>Y+SCY
  595.          NM=1
  596.          While Mouse Key<>0 : Wend 
  597.          SETAUTO
  598.       End If 
  599.    End If 
  600. End If 
  601. While Mouse Key<>0 : Wend 
  602. Return 
  603. Procedure PICKTILE
  604.    Shared A,NM,XSIZE,YSIZE,UTILE,MXLN
  605.    Amal Freeze 
  606.    Sprite Off 8
  607.    Show On 
  608.    Menu Off 
  609.    Screen 2
  610.    Cls 2
  611.    SCW=Deek(Screen Base+76)
  612.    SCH=Deek(Screen Base+78)
  613.    X=SCW/XSIZE
  614.    Y=SCH/YSIZE
  615.    Cls 0
  616.    Ink 1
  617.    A=0 : Repeat 
  618.       B=0 : Repeat 
  619.          Put Block A*X+B+1,B*XSIZE,A*YSIZE
  620.       Inc B : Until B=X
  621.    Inc A : Until A>=Y or A>MXLN
  622.    A=0 : Repeat : Draw 0,A*YSIZE To SCW,A*YSIZE
  623.       Inc A
  624.    Until A=Y
  625.    A=0 : Repeat : Draw A*XSIZE,0 To A*XSIZE,SCH
  626.    Inc A : Until A=X
  627.    Screen Copy 2 To 0
  628.    Screen 0
  629.    While Mouse Key=0 : Wend 
  630.    X2=X Screen(X Mouse)/XSIZE : Y2=Y Screen(Y Mouse)/YSIZE
  631.    UTILE=Y2*X+X2
  632.    UTILE=Min((MXLN+1)*X-1,UTILE)
  633.    Screen 2
  634.    GRABCURSOR
  635.    Screen 0
  636.    Menu On 
  637.    Cls 0
  638. End Proc
  639. Procedure TITLEBAR
  640.    Shared C(),C2(),B,T,D,C
  641.    Hide On 
  642.    Auto View Off 
  643.    Unpack 7 To 2
  644.    Get Icon 1,0,18 To 32,27
  645.    Get Sprite 1,32,28 To 48,44
  646.    A=0 : Repeat 
  647.       Get Sprite A+2,A*16,28 To A*16+16,44
  648.       Hot Spot A+2,$11
  649.       Inc A
  650.    Until A=3
  651.    Screen Display 2,,48,,16
  652.    Ink 0
  653.    Bar 0,28 To 320,200
  654.    A=0 : Repeat : C(A)=Colour(A) : C2(A)=0 : Inc A : Until A=8
  655.    Fade 1
  656.    CPAUSE[1,0]
  657.    Auto View On 
  658.    Screen To Front 2
  659.    B=0 : T=0
  660.    While B<>999
  661.       Read B,B2
  662.       If B<>999
  663.          C2(B)=$FFF : C2(B2)=$FFF
  664.          OT=T
  665.          While T<OT+2
  666.             NEATFADE
  667.             Inc T
  668.          Wend 
  669.       End If 
  670.    Wend 
  671.    OT=T : D=6
  672.    While T<OT+D
  673.       NEATFADE
  674.       Inc T
  675.    Wend 
  676.    Colour 1,$FFF
  677.    Data 4,4,3,5,2,6,7,7,999,999
  678. End Proc
  679. Procedure CPAUSE[C,C2]
  680.    While Colour(C)<>C2 : Wend 
  681. End Proc
  682. Procedure NEATFADE
  683.    Shared C(),C2(),C3(),GTG
  684.    Dim R(5)
  685.    A=0 : Repeat 
  686.       CO=Colour(A)
  687.       R(0)=CO/256
  688.       R(1)=(CO mod 256)/16
  689.       R(2)=CO mod 16
  690.       R(3)=C2(A)/256
  691.       R(4)=(C2(A) mod 256)/16
  692.       R(5)=C2(A) mod 16
  693.       R=0 : Repeat 
  694.          If R(R)<R(R+3)
  695.             R(R)=R(R)+3 : R(R)=Min(R(R),R(R+3))
  696.          End If 
  697.          If R(R)>R(R+3)
  698.             R(R)=R(R)-3 : R(R)=Max(R(R),R(R+3))
  699.          End If 
  700.          Inc R
  701.       Until R=3
  702.       CO=R(0)*256+R(1)*16+R(2)
  703.       Colour A,CO
  704.       If CO=$FFF
  705.          C2(A)=C(A)
  706.          C3(A)=1
  707.       End If 
  708.       Inc A
  709.    Until A=8
  710. End Proc
  711. Procedure MAKEICONS
  712.    Ink 6,1
  713.    Set Paint 1
  714.    Set Pattern 30
  715.    Cls 1
  716.    Bar 0,0 To 15,15 : Get Icon 2,0,0 To 16,16
  717.    Cls 1
  718.    Bar 0,0 To 31,15
  719.    Get Icon 3,0,0 To 32,16
  720.    Cls 1
  721.    Bar 0,0 To 15,31
  722.    Get Icon 4,0,0 To 16,32
  723.    Cls 1
  724.    Bar 0,0 To 31,31
  725.    Get Icon 5,0,0 To 32,32
  726.    Set Pattern 0
  727.    Set Paint 0
  728. End Proc
  729. Rem alert box routine without using the window commands
  730. Rem uses the arrays line$() and button$()
  731. Rem returns button pressed in Q
  732. Procedure ALERT[W,H,C1,C2,NB,NL]
  733.    Shared LINE$(),BUTTON$(),Q
  734.    A=1 : Repeat 
  735.       Reset Zone A
  736.       Inc A
  737.    Until A=4
  738.    W=W*8
  739.    H=H*8
  740.    X=160-W/2
  741.    Y=35-H/2
  742.    Get Block 241,0,Y,320,H+6
  743.    Ink 0
  744.    Bar X+5,Y+5 To X+W+5,Y+H+5
  745.    Ink C1
  746.    Bar X,Y To X+W,Y+H
  747.    Ink C2
  748.    Box X+1,Y+1 To X+W-1,Y+H-1
  749.    S=W/8/(NB+1)+1
  750.    If NB=1
  751.       S=4
  752.    End If 
  753.    Paper C1
  754.    Pen C2
  755.    A=0 : While A<NL
  756.       Locate 0,Y Text(Y)+1+A
  757.       Centre LINE$(A)
  758.       Inc A
  759.    Wend 
  760.    A=0 : While A<NB
  761.       Locate X Text(X)+S/2+S*A,Y Text(Y+H)-2
  762.       Print Border$(Zone$(BUTTON$(A),A+1),2);
  763.    Inc A : Wend 
  764.    Q=0 : While Q<1 or Q>NB
  765.       While Mouse Key=0 : Wend 
  766.       Q=Mouse Zone
  767.    Wend 
  768.    Put Block 241,0,Y
  769.    Del Block 241
  770. End Proc
  771. Procedure GRABCURSOR
  772.    Shared XSIZE,YSIZE,UTILE,MXLN
  773.    UTILE=Min(MXLN*320/XSIZE-1,UTILE)
  774.    Screen 2
  775.    A=1 : C=Colour(0) : Repeat : If Hex$(Colour(A))>Hex$(C)
  776.          Ink A
  777.       End If 
  778.    Inc A : Until A=32
  779.    Put Block UTILE+1,0,0
  780.    Box 0,0 To XSIZE-1,YSIZE-1
  781.    Get Sprite 1,0,0 To XSIZE,YSIZE
  782.    Hot Spot 1,$11
  783.    SETAUTO
  784.    Screen 0
  785. End Proc
  786. Rem TAME Engine Routines 
  787. Rem use these in your own programs if you wish (see MAGIC FOREST)
  788. Procedure GTBLCKS
  789.    Rem This routine converts a screen (screen 2) into icons for use by TAME 
  790.    Rem XSIZE & YSIZE determine the block size (and thus the number of them) 
  791.    Shared XSIZE,YSIZE,XSO,YSO,ICDONE,NCOLS,REZ,SCW,SCH,MXLN
  792.    Screen 0
  793.    Get Palette(2)
  794.    If ICDONE
  795.       Screen 2
  796.       A=Screen Base+72
  797.       SCW=Deek(A+4)
  798.       SCH=Deek(A+6)
  799.       NCOLS=Deek(A+24)
  800.       Cls 2
  801.       A=0 : Repeat 
  802.          B=0 : Repeat 
  803.             Put Block A*(SCW/XSO)+B+1,B*XSO,A*YSO
  804.             Inc B
  805.          Until B>=SCW/XSO
  806.          Inc A
  807.       Until A>=SCH/YSO or A>MXLN
  808.       Del Block 
  809.    End If 
  810.    Screen 2
  811.    XSO=XSIZE
  812.    YSO=YSIZE
  813.    A=0
  814.    Repeat 
  815.       B=0
  816.       Repeat 
  817.          Get Block A*(SCW/XSIZE)+B+1,B*XSIZE,A*YSIZE,XSIZE,YSIZE
  818.          Inc B
  819.       Until B>=SCW/XSIZE
  820.       Inc A
  821.    Until A>=SCH/YSIZE or A>MXLN
  822.    Screen 0
  823.    GRABCURSOR
  824.    ICDONE=1
  825.    Cls 0
  826. End Proc
  827. Procedure TAMEVIEW[TX,TY,TW,TH,XS,YS]
  828.    Rem This routine sets up the window for TAME, and what size tiles you wish 
  829.    Rem to use 
  830.    Shared XSIZE,YSIZE,MAPX,MAPY,TAMEW,TAMEH,TLX,TLY,BRX,BRY
  831.    M$="TAME Map"
  832.    MAPX=Deek(Start(6)) : MAPY=Deek(Start(6)+2)
  833.    XSIZE=XS : YSIZE=YS
  834.    TLX=TX : TLY=TY
  835.    TAMEW=TW : TAMEH=TH
  836.    BRX=TLX+TW*(XSIZE-1)
  837.    BRY=TLY+TH*(YSIZE-1)
  838.    S6=Start(6)+4+MAPX*MAPY
  839.    Doke S6,XSIZE : Doke S6+2,YSIZE
  840.    Doke S6+4,TLX : Doke S6+6,TLY
  841.    Doke S6+8,TAMEW : Doke S6+10,TAMEH
  842.    Doke S6+12,BRX : Doke S6+14,BRY
  843.    A=0 : Repeat : Poke Start(6)-8+A,Asc(Mid$(M$,A+1,1)) : Inc A : Until A=8
  844. End Proc
  845. Procedure TAMEMAP[S,X,Y]
  846.    Rem This routine draws the map in the window set by the TAMEVIEW procedure 
  847.    Rem on screen S, at map co-ordinates X,Y 
  848.    Shared XSIZE,YSIZE,TLX,TLY,TAMEW,TAMEH,BRX,BRY,MXLN
  849.    MXTOS=MXLN*320/XSIZE-1
  850.    MAPX=Deek(Start(6)) : MAPY=Deek(Start(6)+2)
  851.    S6=Start(6)+MAPX*MAPY+4
  852.    XSIZE=Deek(S6) : YSIZE=Deek(S6+2)
  853.    TLX=Deek(S6+4) : TLY=Deek(S6+6)
  854.    TAMEW=Deek(S6+8) : TAMEH=Deek(S6+10)
  855.    BRX=Deek(S6+12) : BRY=Deek(S6+14)
  856.    TEMP=Screen
  857.    Screen S
  858.    S6=Start(6)+4
  859.    WI=TAMEW*XSIZE
  860.    HI=TAMEH*YSIZE
  861.    MAPZ=MAPX*MAPY
  862.    A=0 : A2=Y*MAPX
  863.    Repeat 
  864.       A2=A2 mod MAPZ
  865.       B=0 : B2=X
  866.       Repeat 
  867.          Put Block 1+Min(MXTOS,Peek(S6+(B2 mod MAPX)+A2)),TLX+B,TLY+A
  868.          Add B,XSIZE : Inc B2
  869.       Until B>=WI
  870.       Add A,YSIZE : Add A2,MAPX
  871.    Until A>=HI
  872.    Screen Copy S,TLX,TLY,BRX,BRY To TEMP,TLX,TLY
  873.    Screen TEMP
  874. End Proc
  875. Procedure CREDITS
  876.    Shared LINE$(),BUTTON$()
  877.    LINE$(0)="Tame Map Editor"
  878.    LINE$(1)="(c) Mandarin/Jawx 1990"
  879.    LINE$(2)="         By Shadow Software"
  880.    LINE$(3)="      Version 1.0"
  881.    BUTTON$(0)="O.K"
  882.    ALERT[36,6,7,1,1,4]
  883. End Proc
  884. Procedure CLRTXT
  885.    Ink 6 : Bar 0,28 To 320,90
  886.    Ink 6 : Bar 1,29 To 80,88
  887.    Ink 5 : Polyline 80,29 To 1,29 To 1,88
  888.    Ink 0 : Polyline 80,30 To 80,88 To 1,88
  889.    Ink 6 : Bar 81,29 To 158,88
  890.    Ink 5 : Polyline 158,29 To 81,29 To 81,88
  891.    Ink 0 : Polyline 158,30 To 158,88 To 81,88
  892. End Proc