Advertisement
Yesideez

Wanderer.s

Jan 16th, 2018
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;$VER: WandererLevelEditor.s v1.00 (01-Apr-98)
  2. ;Code by Zeb
  3. ;See the comments at the end of the file...
  4.  
  5.     opt o+,w-
  6.     section main,code
  7.  
  8. ProgStart
  9.     move.l  4.w,a6
  10.     sub.l   a1,a1
  11.     jsr -$126(a6)   ;FindTask(a1)exec
  12.     move.l  d0,a4
  13.     tst.l   $ac(a4)
  14.     bne.b   FromDOS
  15.     lea $5c(a4),a0
  16.     jsr -$180(a6)   ;WaitPort(a0)exec
  17.     lea $5c(a4),a0
  18.     jsr -$174(a6)   ;GetMsg(a0)exec
  19.     move.l  d0,WbMsg
  20. FromDOS lea Dos_L(pc),a1
  21.     moveq.l #0,d0
  22.     bsr OpenLibrary
  23.     move.l  d0,Dos_B
  24.     beq Quit
  25.     lea Intui_L(pc),a1
  26.     moveq.l #0,d0
  27.     bsr OpenLibrary
  28.     move.l  d0,Intui_B
  29.     beq ClDos
  30.     lea Gfx_L(pc),a1
  31.     moveq.l #0,d0
  32.     bsr OpenLibrary
  33.     move.l  d0,Gfx_B
  34.     beq ClIntui
  35.     lea ReqT_L(pc),a1
  36.     moveq.l #37,d0
  37.     bsr OpenLibrary
  38.     move.l  d0,ReqT_B
  39.     beq Err_ShowNoReqTools
  40.     move.l  Intui_B(pc),a6
  41.     lea WinDefs(pc),a0
  42.     jsr -$cc(a6)    ;OpenWindow(a0)int
  43.     move.l  d0,WinPtr
  44.     beq Err_ShowNoWindow
  45.     move.l  d0,a0
  46.     move.l  $32(a0),RPort
  47.     move.l  $56(a0),MsgPort
  48.     lea BoxA1(pc),a1
  49.     bsr DrawBorder
  50.     lea BoxB1(pc),a1
  51.     bsr DrawBorder
  52.     lea BoxC1(pc),a1
  53.     bsr DrawBorder
  54.     moveq.l #1,d0
  55.     bsr SetAPen
  56.     lea MsgText(pc),a4
  57.     moveq.l #11,d0
  58.     moveq.l #21,d1
  59.     moveq.l #40,d7
  60.     bsr PrintText
  61.     lea GadText(pc),a4  ;New
  62.     move.l  #403,d0
  63.     moveq.l #23,d1
  64.     moveq.l #3,d7
  65.     bsr PrintText
  66.     addq.l  #3,a4       ;Load Level
  67.     move.l  #375,d0
  68.     moveq.l #35,d1
  69.     moveq.l #10,d7
  70.     bsr PrintText
  71.     lea 10(a4),a4   ;Save Level
  72.     move.l  #375,d0
  73.     moveq.l #47,d1
  74.     moveq.l #10,d7
  75.     bsr PrintText
  76.     lea 10(a4),a4   ;Set Moves
  77.     move.l  #379,d0
  78.     moveq.l #83,d1
  79.     moveq.l #9,d7
  80.     bsr PrintText
  81.     lea 9(a4),a4    ;Help
  82.     move.l  #399,d0
  83.     moveq.l #107,d1
  84.     moveq.l #4,d7
  85.     bsr PrintText
  86.     moveq.l #0,d0
  87.     bsr SetDrMd
  88.     addq.l  #4,a4       ;Level Info
  89.     move.l  #375,d0
  90.     moveq.l #119,d1
  91.     moveq.l #10,d7
  92.     bsr PrintText
  93.     moveq.l #1,d0
  94.     bsr SetDrMd
  95.     lea 10(a4),a4   ;About
  96.     move.l  #395,d0
  97.     move.l  #131,d1
  98.     moveq.l #5,d7
  99.     bsr PrintText
  100.     addq.l  #5,a4       ;Quit Editor
  101.     move.l  #371,d0
  102.     move.l  #152,d1
  103.     moveq.l #11,d7
  104.     bsr PrintText
  105.     bsr UpdateMap
  106.     bsr CountTreasures
  107. WinLoop move.l  MsgPort(pc),a0
  108.     move.l  4.w,a6
  109.     jsr -$180(a6)   ;WaitPort(a0)exec
  110.     move.l  MsgPort(pc),a0
  111.     move.l  4.w,a6
  112.     jsr -$174(a6)   ;GetMsg(a0)exec
  113.     move.l  d0,a0
  114.     move.l  d0,a5
  115.     move.l  $1C(a0),-(sp)
  116.     move.l  $14(a0),d7
  117.     move.l  d0,a1
  118.     move.l  4.w,a6
  119.     jsr -$17A(a6)   ;ReplyMsg(a1)exec
  120.     move.l  (sp)+,a0
  121.     moveq.l #0,d0
  122.     move.w  $26(a0),d0
  123.     cmp.w   #$40,d7     ;IDCMP_GADGETUP
  124.     beq GadgetSelect
  125.     cmp.l   #$200000,d7 ;IDCMP_VANILLAKEY
  126.     beq VanillaKey
  127.     bra.b   WinLoop
  128. ClWin   move.l  Intui_B(pc),a6
  129.     move.l  WinPtr(pc),a0
  130.     jsr -$48(a6)    ;CloseWindow(a0)int
  131. ClReqT  move.l  ReqT_B(pc),a1
  132.     bsr.b   CloseLibrary
  133. ClGfx   move.l  Gfx_B(pc),a1
  134.     bsr.b   CloseLibrary
  135. ClIntui move.l  Intui_B(pc),a1
  136.     bsr.b   CloseLibrary
  137. ClDos   move.l  Dos_B(pc),a1
  138.     bsr.b   CloseLibrary
  139. Quit    tst.l   WbMsg
  140.     beq.b   QuitDOS
  141.     move.l  4.w,a6
  142.     move.l  WbMsg(pc),a1
  143.     jsr -$17a(a6)   ;ReplyMsg(a1)exec
  144. QuitDOS moveq.l #0,d0
  145.     rts
  146.  
  147. OpenLibrary
  148.     move.l  4.w,a6
  149.     jmp -$228(a6)   ;OpenLibrary(a1,d0)exec
  150.  
  151. CloseLibrary
  152.     move.l  4.w,a6
  153.     jmp -$19e(a6)   ;CloseLibrary(a1)exec
  154.  
  155. DrawBorder
  156.     move.l  Intui_B(pc),a6
  157.     move.l  RPort(pc),a0
  158.     moveq.l #0,d0
  159.     moveq.l #0,d1
  160.     jmp -$6c(a6)    ;DrawBorder(a0,a1,d0,d1)int
  161.  
  162. Err_ShowNoReqTools
  163.     bsr.b   Output
  164.     move.l  d0,d1
  165.     beq.b   ClGfx
  166.     lea NoReqT(pc),a2
  167.     move.l  a2,d2
  168.     moveq.l #43,d3
  169.     bsr.b   Write
  170.     bra.b   ClGfx
  171.  
  172. Err_ShowNoWindow
  173.     bsr.b   Output
  174.     move.l  d0,d1
  175.     beq.b   ClReqT
  176.     lea NoWin(pc),a2
  177.     move.l  a2,d2
  178.     moveq.l #33,d3
  179.     bsr.b   Write
  180.     bra.b   ClReqT
  181.  
  182. Output
  183.     move.l  Dos_B(pc),a6
  184.     jmp -$3c(a6)    ;Output()dos
  185.  
  186. Open
  187.     move.l  Dos_B(pc),a6
  188.     jmp -$1e(a6)    ;Open(d1,d2,d3)dos
  189.  
  190. Read
  191.     move.l  Dos_B(pc),a6
  192.     jmp -$2a(a6)    ;Read(d1,d2,d3)dos
  193.  
  194. Write
  195.     move.l  Dos_B(pc),a6
  196.     jmp -$30(a6)    ;Write(d1,d2,d3)dos
  197.  
  198. Close
  199.     move.l  Dos_B(pc),a6
  200.     jmp -$24(a6)    ;Close(d1)dos
  201.  
  202. GadgetSelect
  203.     cmp.b   #1,d0
  204.     beq CheckNew
  205.     cmp.b   #2,d0
  206.     beq LoadLevel
  207.     cmp.b   #3,d0
  208.     beq SaveLevel
  209.     cmp.b   #6,d0
  210.     beq SetMoves
  211.     cmp.b   #8,d0
  212.     beq ShowHelp
  213.     cmp.b   #10,d0
  214.     beq ShowAbout
  215.     cmp.b   #11,d0
  216.     beq CheckQuit
  217.     bra WinLoop
  218.  
  219. VanillaKey
  220.     move.l  a5,a0
  221.     move.l  20(a0),d0   ;intuimessage.class (IDCMP_VANILLAKEY)
  222.     move.w  24(a0),d1   ;intuimessage.code  (key pressed)
  223.     move.w  26(a0),d2   ;intuimessage.qualifier (shift, alt etc.)
  224.     cmp.b   #"n",d1
  225.     beq CheckNew
  226.     cmp.b   #"l",d1
  227.     beq LoadLevel
  228.     cmp.b   #"v",d1
  229.     beq SaveLevel
  230.     cmp.b   #"e",d1
  231.     beq SetMoves
  232.     cmp.b   #"?",d1
  233.     beq ShowAbout
  234.     cmp.b   #"h",d1
  235.     beq ShowHelp
  236.     cmp.b   #"q",d1
  237.     beq CheckQuit
  238.     cmp.b   #"4",d1
  239.     beq CheckMoveLeft
  240.     cmp.b   #"6",d1
  241.     beq CheckMoveRight
  242.     cmp.b   #"8",d1
  243.     beq CheckMoveUp
  244.     cmp.b   #"2",d1
  245.     beq CheckMoveDown
  246.     cmp.b   #"5",d1
  247.     beq EraseCharacter
  248.     cmp.b   #" ",d1
  249.     beq EraseCharacter
  250.     cmp.b   #"o",d1
  251.     beq InsertUpper
  252.     cmp.b   #"<",d1
  253.     beq InsertCharacter
  254.     cmp.b   #">",d1
  255.     beq InsertCharacter
  256.     cmp.b   #"^",d1
  257.     beq InsertCharacter
  258.     cmp.b   #":",d1
  259.     beq InsertCharacter
  260.     cmp.b   #"!",d1
  261.     beq InsertCharacter
  262.     cmp.b   #"*",d1
  263.     beq InsertCharacter
  264.     cmp.b   #"/",d1
  265.     beq InsertCharacter
  266.     cmp.b   #"\",d1
  267.     beq InsertCharacter
  268.     cmp.b   #"+",d1
  269.     beq InsertCharacter
  270.     cmp.b   #"=",d1
  271.     beq InsertCharacter
  272.     cmp.b   #"#",d1
  273.     beq InsertCharacter
  274.     cmp.b   #"t",d1
  275.     beq InsertUpper
  276.     cmp.b   #"a",d1
  277.     beq InsertUpper
  278.     cmp.b   #"x",d1
  279.     beq InsertUpper
  280.     cmp.b   #"@",d1
  281.     beq InsertCharacter
  282.     cmp.b   #"m",d1
  283.     beq InsertUpper
  284.     cmp.b   #"s",d1
  285.     beq InsertUpper
  286.     cmp.b   #"-",d1
  287.     beq InsertCharacter
  288.     cmp.b   #"c",d1
  289.     beq InsertUpper
  290.     bra WinLoop
  291.  
  292. SetAPen
  293.     move.l  Gfx_B(pc),a6
  294.     move.l  RPort(pc),a1
  295.     jmp -$156(a6)   ;SetAPen(a1,d0)gfx
  296.  
  297. SetBPen
  298.     move.l  Gfx_B(pc),a6
  299.     move.l  RPort(pc),a1
  300.     jmp -$15c(a6)   ;SetCPen(a1,d0)gfx
  301.  
  302. PrintText
  303.     move.l  Gfx_B(pc),a6
  304.     move.l  a4,a0
  305.     move.l  RPort(pc),a1
  306.     jsr -$f0(a6)    ;Move(a1,d0,d1)gfx
  307.     move.l  RPort(pc),a1
  308.     move.l  d7,d0
  309.     jmp -$3c(a6)    ;Text(a1,a0,d0)gfx
  310.  
  311. UpdateMap
  312.     moveq.l #34,d6
  313.     lea Map(pc),a4
  314. .loop   moveq.l #12,d0
  315.     move.l  d6,d1
  316.     moveq.l #40,d7
  317.     bsr.b   PrintText
  318.     lea 41(a4),a4
  319.     addq.l  #8,d6
  320.     cmp.b   #162,d6
  321.     bne.b   .loop
  322.     bsr UpdateCursor
  323.     rts
  324.  
  325. ShowAbout
  326.     lea Rq01T(pc),a0
  327.     lea Rq01B(pc),a1
  328.     lea OkText(pc),a2
  329.     bsr.b   EZRequest
  330.     bra WinLoop
  331.  
  332. CheckQuit
  333.     lea Rq02T(pc),a0
  334.     lea RUSure(pc),a1
  335.     lea YesNo(pc),a2
  336.     bsr.b   EZRequest
  337.     cmp.b   #1,d0
  338.     beq ClWin
  339.     bra WinLoop
  340.  
  341. ShowHelp
  342.     lea Rq03T(pc),a0
  343.     lea Rq03B(pc),a1
  344.     lea MoreXit(pc),a2
  345.     bsr.b   EZRequest
  346.     cmp.b   #1,d0
  347.     beq.b   ShowMoreHelp
  348.     bra WinLoop
  349.  
  350. ShowMoreHelp
  351.     lea Rq05T(pc),a0
  352.     lea Rq05B(pc),a1
  353.     lea OkText(pc),a2
  354.     bsr.b   EZRequest
  355.     bra WinLoop
  356.  
  357. CheckNew
  358.     lea Rq04T(pc),a0
  359.     lea RUSure(pc),a1
  360.     lea YesNo(pc),a2
  361.     bsr.b   EZRequest
  362.     cmp.b   #1,d0
  363.     beq.b   ClearMap
  364.     bra WinLoop
  365.  
  366. EZRequest
  367.     move.l  ReqT_B(pc),a6
  368.     move.w  #0,a3
  369.     move.w  #0,a4
  370.     jmp -$42(a6)    ;RtEZRequest(a1,a2,a3,a4,a0)rt
  371.  
  372. CountTreasures
  373.     lea Map(pc),a0
  374.     move.l  #655,d0
  375.     moveq.l #0,d1
  376. .next   cmp.b   #'*',(a0)+
  377.     beq.b   .found
  378.     dbra    d0,.next
  379.     bra.b   .exit
  380. .found  addq.l  #1,d1
  381.     dbra    d0,.next
  382. .exit   rts
  383.  
  384. ClearMap
  385.     lea Map(pc),a0
  386.     moveq.l #15,d0
  387. .row    moveq.l #9,d1
  388. .loop   move.l  #'    ',(a0)+
  389.     dbra    d1,.loop
  390.     addq.l  #1,a0
  391.     dbra    d0,.row
  392.     bsr UpdateMap
  393.     lea Cleared(pc),a4
  394.     bsr ShowMessage
  395.     bra WinLoop
  396.  
  397. LoadLevel
  398.     lea Temp(pc),a0
  399.     move.b  #0,(a0)
  400.     moveq.l #0,d0
  401.     bsr AllocRequest
  402.     move.l  d0,ReqPtr
  403.     beq Err_NoRequester
  404.     lea Rf01Tl(pc),a3
  405.     move.l  #'Load',(a3)
  406.     bsr FileRequest
  407.     tst.l   d0
  408.     beq.b   .free
  409.     lea ReqPtr(pc),a1
  410.     move.l  (a1),a1
  411.     move.l  16(a1),a0
  412.     lea LoadFil(pc),a1
  413.     bsr ExtractPathFile
  414.     lea LoadFil(pc),a0
  415.     bsr GetFileSize
  416.     sub.l   #697,d0
  417.     move.l  d0,FileLen
  418.     bsr LoadLevelFile
  419.     bsr UpdateMap
  420.     lea DiskOk(pc),a4
  421.     move.l  #'load',5(a4)
  422.     move.l  #'ed o',9(a4)
  423.     move.l  #'k.  ',13(a4)
  424.     bsr ShowMessage
  425. .free   bsr FreeRequest
  426.     bra WinLoop
  427.  
  428. SaveLevel
  429.     lea Temp(pc),a0
  430.     move.b  #0,(a0)
  431.     moveq.l #0,d0
  432.     bsr.b   AllocRequest
  433.     move.l  d0,ReqPtr
  434.     beq Err_NoRequester
  435.     lea Rf01Tl(pc),a3
  436.     move.l  #'Save',(a3)
  437.     bsr.b   FileRequest
  438.     tst.l   d0
  439.     beq.b   .free
  440.     lea ReqPtr(pc),a1
  441.     move.l  (a1),a1
  442.     move.l  16(a1),a0
  443.     lea SaveFil(pc),a1
  444.     bsr.b   ExtractPathFile
  445.     bsr SaveLevelFile
  446.     lea DiskOk(pc),a4
  447.     move.l  #'save',5(a4)
  448.     move.l  #'d ok',9(a4)
  449.     move.l  #'.   ',13(a4)
  450.     bsr ShowMessage
  451. .free   bsr.b   FreeRequest
  452.     bra WinLoop
  453.  
  454. ExtractPathFile
  455.     movem.l d0-d7/a0-a6,-(sp)
  456.     clr.b   (a5)
  457. .loopp  move.b  (a0)+,(a1)+
  458.     bne.b   .loopp
  459.     cmp.w   #$3a00,-(a1)    ;":"0
  460.     beq.b   .back
  461.     move.b  (a1)+,(a5)
  462.     move.b  #'/',(a1)+
  463.     bra.b   .loopn
  464. .back   move.b  (a1)+,(a5)
  465. .loopn  move.b  (a2)+,(a1)+
  466.     bne.b   .loopn
  467. .exit   movem.l (sp)+,d0-d7/a0-a6
  468.     rts
  469.  
  470. AllocRequest
  471.     move.l  ReqT_B(pc),a6
  472.     move.w  #0,a0
  473.     jmp -$1e(a6)    ;RtAllocRequestA(d0,a0)rt
  474.  
  475. FreeRequest
  476.     move.l  ReqT_B(pc),a6
  477.     move.l  ReqPtr(pc),a1
  478.     jmp -$24(a6)    ;RtFreeRequest(a1)rt
  479.  
  480. FileRequest
  481.     move.l  ReqT_B(pc),a6
  482.     lea Rf01T(pc),a0
  483.     move.l  ReqPtr(pc),a1
  484.     lea Temp(pc),a2
  485.     jmp -$36(a6)    ;RtFileRequestA(a1,a2,a3,a0)rt
  486.  
  487. GetFileSize
  488.     move.l  Dos_B(pc),a6
  489.     move.l  a0,d1
  490.     moveq.l #-2,d2
  491.     jsr -$54(a6)    ;Lock(d1,d2)dos
  492.     move.l  d0,FileLok
  493.     beq.b   .quit
  494.     move.l  Dos_B(pc),a6
  495.     move.l  FileLok(pc),d1
  496.     move.l  #NfoBlok,d2
  497.     jsr -$66(a6)    ;Examine(d1/d2)dos
  498.     tst.l   d0
  499.     beq.b   .noinfo
  500.     lea NfoBlok,a0
  501.     move.l  $7c(a0),-(sp)
  502. .noinfo move.l  Dos_B(pc),a6
  503.     move.l  FileLok(pc),d1
  504.     jsr -$5a(a6)    ;UnLock(d1)dos
  505.     move.l  (sp)+,d0
  506. .quit   rts
  507.  
  508. LoadLevelFile
  509.     lea LoadFil(pc),a1
  510.     move.l  a1,d1
  511.     move.l  #$3ed,d2
  512.     bsr Open
  513.     move.l  d0,FilePtr
  514.     beq Err_DiskError
  515.     move.l  d0,d1
  516.     lea Map(pc),a2
  517.     move.l  a2,d2
  518.     move.l  #656,d3
  519.     bsr Read
  520.     move.l  FilePtr(pc),d1
  521.     lea Temp(pc),a2
  522.     move.l  a2,d2
  523.     moveq.l #41,d3
  524.     bsr Read
  525.     move.l  FilePtr(pc),d1
  526.     lea Moves(pc),a2
  527.     move.l  a2,d2
  528.     move.l  #"    ",(a2)
  529.     move.l  FileLen(pc),d3
  530.     bsr Read
  531.     move.l  FilePtr(pc),d1
  532.     bsr Close
  533.     bsr ShowMaxMoves
  534.     rts
  535.  
  536. SaveLevelFile
  537.     lea SaveFil(pc),a1
  538.     move.l  a1,d1
  539.     move.l  #$3ee,d2
  540.     bsr Open
  541.     move.l  d0,FilePtr
  542.     beq.b   Err_DiskError
  543.     move.l  d0,d1
  544.     lea Map(pc),a2
  545.     move.l  a2,d2
  546.     move.l  #697,d3
  547.     bsr Write
  548.     move.l  FilePtr(pc),d1
  549.     lea Moves(pc),a2
  550.     move.l  a2,d2
  551.     move.l  FileLen(pc),d3
  552.     bsr Write
  553.     move.l  FilePtr(pc),d1
  554.     bsr Close
  555.     rts
  556.  
  557. Err_DiskError
  558.     lea DiskErr(pc),a4
  559.     bsr ShowMessage
  560.     bra WinLoop
  561.  
  562. SetMoves
  563.     moveq.l #5,d0       ;type
  564.     bsr AllocRequest
  565.     move.l  d0,ReqPtr
  566.     beq.b   Err_NoRequester
  567.     lea Rl01T(pc),a0
  568.     lea MovesD(pc),a1
  569.     bsr.b   GetLong
  570.     lea MovesD(pc),a1
  571.     lea Moves(pc),a0
  572.     move.l  (a1),d1
  573.     bsr.b   DecToAscii
  574.     bsr FreeRequest
  575.     bra WinLoop
  576.  
  577. GetLong
  578.     move.l  ReqT_B(pc),a6
  579.     move.w  #0,a2
  580.     move.l  ReqPtr(pc),a3
  581.     jmp -$4e(a6)    ;RtGetLongA(a1,a2,a3,a0)rt
  582.  
  583. Err_NoRequester
  584.     lea NoReqP(pc),a4
  585.     bsr ShowMessage
  586.     bra WinLoop
  587.  
  588. DecToAscii
  589.     divu    #1000,d1
  590.     bsr.b   .digit
  591.     divu    #100,d1
  592.     bsr.b   .digit
  593.     divu    #10,d1
  594.     bsr.b   .digit
  595.     nop
  596. .digit  add #$30,d1
  597.     move.b  d1,(a0)+
  598.     clr d1
  599.     swap    d1
  600.     rts
  601.  
  602. ShowMaxMoves
  603.     lea MovesIs(pc),a4
  604.     lea Moves(pc),a1
  605.     move.l  #"    ",27(a4)
  606.     move.l  (a1),27(a4)
  607.     moveq.l #11,d0
  608.     moveq.l #21,d1
  609.     moveq.l #40,d7
  610.     bsr PrintText
  611.     rts
  612.  
  613. CheckMoveLeft
  614.     cmp.w   #1,X_Pos
  615.     ble WinLoop
  616.     bsr UpdateCursor
  617.     subq.w  #1,X_Pos
  618.     bra.b   UpdateX_Pos
  619.  
  620. CheckMoveRight
  621.     cmp.w   #40,X_Pos
  622.     bge WinLoop
  623.     bsr.b   UpdateCursor
  624.     addq.w  #1,X_Pos
  625.     bra.b   UpdateX_Pos
  626.  
  627. CheckMoveUp
  628.     cmp.w   #1,Y_Pos
  629.     ble WinLoop
  630.     bsr.b   UpdateCursor
  631.     subq.w  #1,Y_Pos
  632.     bra.b   UpdateY_Pos
  633.  
  634. CheckMoveDown
  635.     cmp.w   #16,Y_Pos
  636.     bge WinLoop
  637.     bsr.b   UpdateCursor
  638.     addq.w  #1,Y_Pos
  639.     bra.b   UpdateY_Pos
  640.  
  641. UpdateX_Pos
  642.     lea MsgText(pc),a0
  643.     addq.l  #2,a0
  644.     move.w  X_Pos,d1
  645.     bsr.b   ConvertCoords
  646.     bsr.b   UpdateMessage
  647.     bra.b   ContinueXY
  648.  
  649. UpdateY_Pos
  650.     lea MsgText(pc),a0
  651.     addq.l  #7,a0
  652.     move.w  Y_Pos,d1
  653.     bsr.b   ConvertCoords
  654.     bsr.b   UpdateMessage
  655.  
  656. ContinueXY
  657.     bsr.b   UpdateCursor
  658.     bra WinLoop
  659.  
  660. ConvertCoords
  661.     divu    #10,d1
  662.     bsr.b   .digit
  663.     nop
  664. .digit  add #$30,d1
  665.     move.b  d1,(a0)+
  666.     clr d1
  667.     swap    d1
  668.     rts
  669.  
  670. UpdateCursor
  671.     moveq.l #-1,d0
  672.     bsr.b   SetDrMd
  673.     moveq.l #3,d0
  674.     bsr SetAPen
  675.     moveq.l #0,d0
  676.     bsr SetBPen
  677.     moveq.l #0,d0
  678.     moveq.l #0,d1
  679.     move.w  X_Pos(pc),d0
  680.     bsr.b   CalculateX
  681.     move.w  Y_Pos(pc),d1
  682.     bsr.b   CalculateY
  683.     move.l  d0,d2
  684.     move.l  d1,d3
  685.     bsr.b   ShowCursor
  686.     moveq.l #1,d0
  687.     bsr SetAPen
  688.     move.l  Gfx_B(pc),a6
  689.     move.l  RPort(pc),a1
  690.     moveq.l #1,d0
  691.     bsr.b   SetDrMd
  692.     rts
  693.  
  694. UpdateMessage
  695.     lea MsgText(pc),a4
  696.     moveq.l #11,d0
  697.     moveq.l #21,d1
  698.     moveq.l #40,d7
  699.     bsr PrintText
  700.     rts
  701.  
  702. CalculateX
  703.     mulu.w  #8,d0
  704.     addq.w  #4,d0
  705.     rts
  706.  
  707. CalculateY
  708.     mulu.w  #8,d1
  709.     add.w   #26,d1
  710.     rts
  711.  
  712. ShowCursor
  713.     lea Crsr(pc),a4
  714.     moveq.l #1,d7
  715.     bsr PrintText
  716.     rts
  717.  
  718. SetDrMd
  719.     move.l  Gfx_B(pc),a6
  720.     move.l  RPort(pc),a1
  721.     jmp -$162(a6)   ;SetDrMd(a1,d0)gfx
  722.  
  723. EraseCharacter
  724.     move.b  #32,d1
  725.     bra.b   InsertCharacter
  726.  
  727. InsertUpper
  728.     sub.b   #" ",d1
  729.  
  730. InsertCharacter
  731.     move.w  d1,d7
  732.     moveq.l #0,d0
  733.     move.w  Y_Pos(pc),d0
  734.     mulu.w  #41,d0
  735.     sub.w   #41,d0
  736.     add.w   X_Pos(pc),d0
  737.     subq.w  #1,d0
  738.     lea Map(pc),a0
  739.     add.l   d0,a0
  740.     move.b  d7,(a0)
  741.     bsr UpdateMap
  742.     bra WinLoop
  743.  
  744. ShowMessage
  745.     moveq.l #11,d0
  746.     moveq.l #21,d1
  747.     moveq.l #40,d7
  748.     bsr PrintText
  749.     rts
  750.  
  751. Dos_L   dc.b    'dos.library',0
  752. Intui_L dc.b    'intuition.library',0
  753. Gfx_L   dc.b    'graphics.library',0
  754. ReqT_L  dc.b    'reqtools.library',0
  755. Dos_B   dc.l    0
  756. Intui_B dc.l    0
  757. Gfx_B   dc.l    0
  758. ReqT_B  dc.l    0
  759. FilePtr dc.l    0
  760. MsgPort dc.l    0
  761. RPort   dc.l    0
  762. ReqPtr  dc.l    0
  763. FileLok dc.l    0
  764. FileLen dc.l    5
  765. X_Pos   dc.w    1
  766. Y_Pos   dc.w    1
  767. WbMsg   dc.l    0
  768. NoReqT  dc.b    'ERROR: Unable to open reqtools.library v37',$a
  769. NoWin   dc.b    'ERROR: Unable to open the window',$a
  770. WinDefs dc.w    0,11            ;x,y
  771.     dc.w    499,161         ;w,h
  772.     dc.b    0,1         ;detailPen,blockPen
  773.     dc.l    $200040         ;IDCMP:GADGETUP!VANILLAKEY
  774.     dc.l    $11006          ;WFLG:DRAGBAR!DEPTHGADGET!CLOSEGADGET!ACTIVATE!RMBTRAP
  775.     dc.l    Gad01           ;first gadget
  776.     dc.l    0           ;checkmark image
  777.     dc.l    WinTitl         ;Window title
  778.     dc.l    0           ;screen
  779.     dc.l    0           ;bitmap
  780.     dc.w    50,20           ;min w,min h
  781.     dc.w    640,256         ;max w,max h
  782.     dc.w    1           ;in workbench
  783. WinTitl dc.b    'Wanderer Level Editor by Zeb',0
  784. WinPtr  dc.l    0
  785. SmlFont dc.l    TopazF,$80000
  786. BigFont dc.l    TopazF,$90000
  787. TopazF  dc.b    'topaz.font',0
  788. Gad01   dc.l    Gad02           ;New
  789.     dc.w    343,15,144,11
  790.     dc.w    2,1,1
  791.     dc.l    BdrUp3,BdrDn3,0,0,0
  792.     dc.w    1
  793.     dc.l    0
  794. Gad02   dc.l    Gad03           ;Load Level
  795.     dc.w    343,27,144,11
  796.     dc.w    2,1,1
  797.     dc.l    BdrUp3,BdrDn3,0,0,0
  798.     dc.w    2
  799.     dc.l    0
  800. Gad03   dc.l    Gad04           ;Save Level
  801.     dc.w    343,39,144,11
  802.     dc.w    2,1,1
  803.     dc.l    BdrUp3,BdrDn3,0,0,0
  804.     dc.w    3
  805.     dc.l    0
  806. Gad04   dc.l    Gad05           ;DISABLED
  807.     dc.w    343,51,144,11
  808.     dc.w    $103,1,1
  809.     dc.l    BdrUp3,BdrDn3,0,0,0
  810.     dc.w    4
  811.     dc.l    0
  812. Gad05   dc.l    Gad06           ;DISABLED
  813.     dc.w    343,63,144,11
  814.     dc.w    $103,1,1
  815.     dc.l    BdrUp3,BdrDn3,0,0,0
  816.     dc.w    5
  817.     dc.l    0
  818. Gad06   dc.l    Gad07           ;Set Moves
  819.     dc.w    343,75,144,11
  820.     dc.w    2,1,1
  821.     dc.l    BdrUp3,BdrDn3,0,0,0
  822.     dc.w    6
  823.     dc.l    0
  824. Gad07   dc.l    Gad08           ;DISABLED
  825.     dc.w    343,87,144,11
  826.     dc.w    $103,1,1
  827.     dc.l    BdrUp3,BdrDn3,0,0,0
  828.     dc.w    7
  829.     dc.l    0
  830. Gad08   dc.l    Gad09           ;Help
  831.     dc.w    343,99,144,11
  832.     dc.w    2,1,1
  833.     dc.l    BdrUp3,BdrDn3,0,0,0
  834.     dc.w    8
  835.     dc.l    0
  836. Gad09   dc.l    Gad10           ;Level Info
  837.     dc.w    343,111,144,11
  838.     dc.w    $302,1,1
  839.     dc.l    BdrUp3,BdrDn3,0,0,0
  840.     dc.w    9
  841.     dc.l    0
  842. Gad10   dc.l    Gad11           ;About
  843.     dc.w    343,123,144,11
  844.     dc.w    2,1,1
  845.     dc.l    BdrUp3,BdrDn3,0,0,0
  846.     dc.w    10
  847.     dc.l    0
  848. Gad11   dc.l    0           ;Quit Editor
  849.     dc.w    343,144,144,11
  850.     dc.w    2,1,1
  851.     dc.l    BdrUp3,BdrDn3,0,0,0
  852.     dc.w    11
  853.     dc.l    0
  854. BdrUp3  dc.w    0,-1
  855.     dc.l    $1020005,BdrUp3L,BdrUp4
  856. BdrUp3L dc.w    0,11, 143,11, 143,1, 142,2, 142,11
  857. BdrUp4  dc.w    0,-1
  858.     dc.l    $2010005,BdrUp4L,0
  859. BdrUp4L dc.w    142,1, 0,1, 0,11, 1,10, 1,1
  860. BdrDn3  dc.w    0,-1
  861.     dc.l    $2010005,BdrDn3L,BdrDn4
  862. BdrDn3L dc.w    0,11, 143,11, 143,1, 142,2, 142,11
  863. BdrDn4  dc.w    0,-1
  864.     dc.l    $1020005,BdrDn4L,0
  865. BdrDn4L dc.w    142,1, 0,1, 0,11, 1,10, 1,1
  866. BoxA1   dc.w    8,12            ;Message window
  867.     dc.l    $2010005,BoxA1L,BoxA2
  868. BoxA1L  dc.w    0,11, 326,11, 326,1, 325,2, 325,11
  869. BoxA2   dc.w    8,12
  870.     dc.l    $1020005,BoxA2L,0
  871. BoxA2L  dc.w    325,1, 0,1, 0,11, 1,10, 1,1
  872. BoxB1   dc.w    8,25            ;Map window
  873.     dc.l    $2010005,BoxB1L,BoxB2
  874. BoxB1L  dc.w    0,131, 326,131, 326,1, 325,2, 325,131
  875. BoxB2   dc.w    8,25
  876.     dc.l    $1020005,BoxB2L,0
  877. BoxB2L  dc.w    325,1, 0,1, 0,131, 1,130, 1,1
  878. BoxC1   dc.w    339,12          ;Gadgets window
  879.     dc.l    $2010005,BoxC1L,BoxC2
  880. BoxC1L  dc.w    0,144, 151,144, 151,1, 150,2, 150,144
  881. BoxC2   dc.w    339,12
  882.     dc.l    $1020005,BoxC2L,0
  883. BoxC2L  dc.w    150,1, 0,1, 0,144, 1,143, 1,1
  884. MsgText dc.b    'X=01 Y=01 *=000 C=?                     '
  885. MovesIs dc.b    'Maximum number of moves is XXXX         '
  886. DiskOk  dc.b    'File loaded ok.                         '
  887. DiskErr dc.b    'Problem accessing file                  '
  888. NoReqP  dc.b    'Problem allocating ReqTools requester   '
  889. Cleared dc.b    'Here you are, have a nice empty level...'
  890. GadText dc.b    'NewLoad LevelSave LevelSet MovesHelpLevel InfoAboutQuit Editor'
  891. Map dc.b    '=======================\OOO*OOOO/#OO####',$a
  892.     dc.b    '*O       O:#         O/ \OOOOOO/# ::A**#',$a
  893.     dc.b    '# O #### #:#       **/   \OOOO/   ######',$a
  894.     dc.b    '# #  O  *#:#              \OO/   ##    -',$a
  895.     dc.b    '# #* * ###:# OOO           O/    ##    -',$a
  896.     dc.b    '# ######:::#*****         :/  *###* O  -',$a
  897.     dc.b    '#    #*                 @     *<*###*< -',$a
  898.     dc.b    '#*#! ###                  \   *###*    -',$a
  899.     dc.b    '###              !     ::  \     ##    -',$a
  900.     dc.b    '# #          \ /=O=   ::::   \O     / O/',$a
  901.     dc.b    '#*           O O  =    ::   / \*   / */-',$a
  902.     dc.b    '###         #***# =        /   \    O/ -',$a
  903.     dc.b    'X < !!!     #\*/# =       /    O*O*O*O -',$a
  904.     dc.b    '>*   *   *<  # #  =      /     =**O*O= -',$a
  905.     dc.b    '    !!!   ! !# #! =! \    /    =:O*O:= -',$a
  906.     dc.b    '          ! *#T#*:::::\**/     =::::::*-',$a
  907.     dc.b    '########################################',$a
  908. Moves   dc.b    '1000',$a,0
  909. Rq01T   dc.l    $8000000b,'_'       ;RT_UNDERSCORE
  910.     dc.l    $80000014,Rq01Tl    ;RTEZ_REQTITLE
  911.     dc.l    $80000016,4     ;RTEZ_FLAGS (EZREQF_CENTERTEXT)
  912.     dc.l    0           ;End of taglist
  913. Rq01Tl  dc.b    'About...',0
  914. Rq01B   dc.b    'Wanderer Level Editor v1.00',$a
  915.     dc.b    'by Zeb (01-Apr-98)',$a,$a
  916.     dc.b    'Written using assembler',$a,0
  917. OkText  dc.b    '_Ok',0
  918. Rq02T   dc.l    $8000000b,'_'       ;RT_UNDERSCORE
  919.     dc.l    $80000014,Rq02Tl    ;RTEZ_REQTITLE
  920.     dc.l    $80000017,0     ;RTEZ_DEFAULTRESPONSE
  921.     dc.l    0           ;End of taglist
  922. Rq02Tl  dc.b    'Quit...',0
  923. RUSure  dc.b    'Are you sure ?',0
  924. YesNo   dc.b    '_Yes|_No',0
  925. Rq03T   dc.l    $8000000b,'_'       ;RT_UNDERSCORE
  926.     dc.l    $80000014,Rq03Tl    ;RTEZ_REQTITLE
  927.     dc.l    $80000017,0     ;RTEZ_DEFAULTRESPONSE
  928.     dc.l    0           ;End of taglist
  929. Rq03Tl  dc.b    'Help (Symbols)...',0
  930. Rq03B   dc.b    'O  Boulder',$a
  931.     dc.b    '<> Arrows',$a
  932.     dc.b    '^  Balloon',$a
  933.     dc.b    ':  Earth',$a
  934.     dc.b    '!  Bomb',$a
  935.     dc.b    '*  Treasure',$a
  936.     dc.b    '/\ Slopes',$a
  937.     dc.b    '+  Cage',$a
  938.     dc.b    '=# Rock',$a
  939.     dc.b    'T  Teleport',$a
  940.     dc.b    'A  Arrival (1 max)',$a
  941.     dc.b    'X  Exit (always 1)',$a
  942.     dc.b    '@  Start (always 1)',$a
  943.     dc.b    'M  Big monster (1 max)',$a
  944.     dc.b    'S  Baby monster',$a
  945.     dc.b    '-  Alternative space',$a
  946.     dc.b    'C  Time capsule',0
  947. MoreXit dc.b    '_More|_Cancel',0
  948. Rq04T   dc.l    $8000000b,'_'       ;RT_UNDERSCORE
  949.     dc.l    $80000014,Rq04Tl    ;RTEZ_REQTITLE
  950.     dc.l    $80000017,0     ;RTEZ_DEFAULTRESPONSE
  951.     dc.l    0           ;End of taglist
  952. Rq04Tl  dc.b    'New...',0
  953. Rf01Tl  dc.b    'ZBD! Level...',0
  954.     even
  955. LoadFil dcb.b   255,0
  956. SaveFil dcb.b   255,0
  957. Temp    dcb.b   255,0
  958. Rf01T   dc.l    $8000000b,'_',$8000002a,OkText,0
  959. Rq05T   dc.l    $8000000b,'_'       ;RT_UNDERSCORE
  960.     dc.l    $80000014,Rq05Tl    ;RTEZ_REQTITLE
  961.     dc.l    $80000017,0     ;RTEZ_DEFAULTRESPONSE
  962.     dc.l    0           ;End of taglist
  963. Rq05B   dc.b    '4  Left            6  Right',$a
  964.     dc.b    '8  Up              2  Down',$a
  965.     dc.b    '5  Erase           H  Help',$a
  966.     dc.b    'N  New             L  Load Level',$a
  967.     dc.b    'V  Save Level      E  Set Moves',$a
  968.     dc.b    'I  Level Info      ?  About',$a
  969.     dc.b    'Q  Quit Editor',$a,$a
  970.     dc.b    'Press the key corresponding to',$a
  971.     dc.b    'the desired symbol to insert it.',0
  972. Rq05Tl  dc.b    'Help (Controls)...',0
  973. Rl01T   dc.l    $80000022,AccCncl   ;RTGS_GADFMT
  974.     dc.l    $80000026,Rl01B     ;RTGS_TEXTFMT
  975.     dc.l    $80000016,4     ;RTGS_FLAGS,GSREQF_CENTERTEXT
  976.     dc.l    $8000000b,'_'       ;RT_UNDERSCORE
  977.     dc.l    0
  978. MovesD  dc.l    1000
  979. AccCncl dc.b    '_Accept|_Cancel',0
  980. Rl01B   dc.b    'Enter the number of moves:',0
  981. Crsr    dc.b    '?'
  982.  
  983.     section fib,data
  984.     cnop    0,4
  985.  
  986. NfoBlok dcb.b   260,0
  987.     end
  988.  
  989. I knocked this up in a day before I realised that there were pull-down menus
  990. telling me that there was an editor already built-in.  I hope you enjoy this
  991. code even though I admit it's not been tidied up much - I didn't see much
  992. point after using the built-in editor!
  993.  
  994. It assembles fine using DevPac (which I used to write it) and although I've
  995. not been able to test it, it should work on Kickstart 1.3 upwards but the
  996. only problem will arise with reqtools.library.
  997.  
  998. No external files are required during assembly.  I *HATE* includes!!!   :D
  999.  
  1000. Zebedee
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement