home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / mapsrc.lha / map.s < prev    next >
Encoding:
Text File  |  1980-02-19  |  8.9 KB  |  544 lines

  1.  
  2. ;--------------------------------------------------------------------------
  3. ;Map Designer ©1994 Rombust/Nebula
  4. ;
  5. ;This source is public domain. It is part of my coding tutorial
  6. ;You can do what you want with it (within reason)
  7. ;It is only a preview version
  8. ;
  9. ;Contact me at: Mark, 50 victoria avenue, sleaford, lincs. NG34 7LN
  10. ;
  11. ;Sorry the source is untidy, but who cares...
  12. ;
  13. ;--------------------------------------------------------------------------
  14.  
  15.     rsreset
  16. filebase:    rs.l 1
  17.  
  18.     opt o+,w-
  19.     opt d+
  20.  
  21.     section code,code
  22.  
  23.     include map.join
  24. diskopt_currantfile set filebase
  25. block_next equ 0
  26. block_prev equ 4
  27. block_number equ 8
  28. block_name equ 10
  29. block_anim equ 12
  30. block_animspecial equ 14
  31. block_special equ 18
  32. block_gfx equ 22
  33. screenwidth equ 40
  34.  
  35. Start:
  36.  
  37.     lea variables,a5
  38.     lea _evar(a5),a0
  39.     move.l a5,a1
  40. .clear    clr.b (a1)+
  41.     cmp.l a0,a1
  42.     bne .clear
  43.  
  44.     move.l 4.w,exec(a5)
  45.  
  46.     opendos
  47.     opengfx
  48.     openint
  49.     getconoutput
  50.  
  51.     bsr main
  52.     
  53.     bsr releaseall
  54.     bsr unlock
  55.     closeint
  56.     closegfx
  57.     closedos
  58.  
  59.     rts
  60.  
  61. main:
  62.     move.l a7,bye(a5)
  63.  
  64.     *lea extramess,a0
  65.     *bsr plotmess
  66.     *bsr readkey
  67.  
  68.     lea startmess,a0
  69.     bsr plotmess
  70.     bsr askyn
  71.     beq .loadit
  72.     bsr newproject
  73. .bat    bsr openscreen
  74.     beq .opened
  75.     lea noscreen,a0
  76.     bsr plotmess
  77.     bsr readkey
  78.     rts
  79. .opened
  80.     move.l blockbase(a5),currentblockadr(a5)
  81.     move.w #0,currentblock(a5)
  82.     bsr programstart
  83.     
  84. .exit    rts
  85.  
  86. .loadit    bsr loaddata
  87.     beq .bat
  88.     rts
  89.  
  90. extramess:
  91.     dc.b "Preview of the map maker",10,10,10
  92.     dc.b "This Version is PD Demo version",10,10
  93.     dc.b "DO NOT SPREAD",10
  94.     dc.b "DO NOT SPREAD",10
  95.     dc.b "DO NOT SPREAD",10
  96.     dc.b "DO NOT SPREAD",10
  97.     dc.b "DO NOT SPREAD",10
  98.     dc.b "DO NOT SPREAD",10
  99.     dc.b "DO NOT SPREAD",10
  100.     dc.b "Press that big key called Return (or hit Enter!) :",0
  101.     even
  102. programstart:
  103.     move.w #0,windowtype(a5)
  104.     bsr updatewindow
  105.     beq adit
  106.     bsr scrback
  107.     lea windowerror,a0
  108.     bsr plotmess
  109.     bsr readkey
  110.     rts
  111.  
  112. adit
  113. .mess
  114.     move.l userport(a5),a0
  115.     move.l windowhd(a5),a4
  116.     move.l exec(a5),a6
  117.     jsr -384(a6)
  118.     move.l 12(a4),d7
  119.     move.l userport(a5),a0
  120.     jsr -372(a6)
  121.     tst.l d0
  122.     beq .mess
  123.     
  124.     move.l d0,a1
  125.     move.l 20(a1),d6
  126.     move.l $1c(a1),a4
  127.  
  128.     jsr -378(a6)
  129.  
  130.     cmp.l #$8,d6
  131.     bne .nomouse
  132.     
  133.     move.w d7,mousex(a5)
  134.     swap d7
  135.     move.w d7,mousey(a5)
  136.     lea windowmouse,a0
  137.     moveq.l #0,d0
  138.     move.w windowtype(a5),d0
  139.     lsl.l #3,d0
  140.  
  141.     btst #6,$bfe001
  142.     bne .nomousea
  143.  
  144.     move.l (a0,d0.l),d0
  145.     beq .cont
  146.     move.l d0,a4
  147.     jsr (a4)
  148.     bra .cont
  149. .nomousea
  150.  
  151.     BTST    #$2,$DFF016    ;$a
  152.     BNE.S    .nomouse
  153.     lea 4(a0),a0
  154.     move.l (a0,d0.l),d0
  155.     beq .cont
  156.     move.l d0,a4
  157.     jsr (a4)
  158.  
  159.     bra .cont
  160.  
  161. .nomouse
  162.     cmp.l #$40,d6
  163.     bne .mess
  164.  
  165.     move.l $42(a4),a4
  166.     jsr (a4)
  167. .cont
  168.     tst.w exitbit(a5)
  169.     beq .mess    
  170.     rts
  171.  
  172. windowpallete:
  173.     ;    pallete        gadgets        idcmp    setup    pal2_y_pos
  174.     dc.l normalpallete,maingad1,$40,0,0        ;window 0
  175.     dc.l pallete,palgad1,$40+8,0,73            ;window 1
  176.     dc.l normalpallete,editgad1,$40+8,0,0        ;window 2
  177.     dc.l pallete,drawgad1,$40+8,0,208        ;window 3
  178.     dc.l normalpallete,choosegad1,$40,0,0        ;window 4
  179.  
  180.  
  181. windowmouse: 
  182.     dc.l 0,0
  183.     dc.l palmouse,0
  184.     dc.l 0,editactual
  185.     dc.l editmouse,endeditactual
  186.     
  187.  
  188. g_deleteblock:
  189.     rts
  190.  
  191. g_saveiffblock:
  192.     rts
  193.  
  194. g_loadiffblock:
  195.     bsr scrback
  196.     lea txtloadiff,a0
  197.     bsr plotmess
  198.     bsr choosefile
  199.     tst.b (a0)
  200.     beq .exit
  201.     move.l a0,d1
  202.     bsr openoldfile
  203.     bne .exit2
  204.     lea tempspace(a5),a0
  205.     move.l #12,d0
  206.     bsr loadtofile
  207.     bne .exit2
  208.     cmp.l #"FORM",tempspace(a5)
  209.     bne .notiff
  210.     cmp.l #"ILBM",8+tempspace(a5)
  211.     bne .notiff
  212.  
  213.     lea tempspace(a5),a0
  214.     move.l #"BMHD",d0
  215.     bsr findhunk
  216.     bne .notiff
  217.     moveq.l #0,d0
  218.     move.b 8(a0),d0
  219.     cmp.w bitplanes(a5),d0
  220.     bne .wrongbp
  221.     move.w (a0),d0        ;width
  222.     move.w 2(a0),d1        ;height
  223.     move.b 10(a0),d2    ;compression
  224.     move.w d0,d3
  225.     lsr.w #3,d3
  226.     cmp.w blockwidth(a5),d3
  227.     blo .wrongdims
  228.     cmp.w blockheight(a5),d1
  229.     blo .wrongdims
  230.     
  231.     
  232.     
  233.     movem.l d0-d2,-(sp)
  234.     bsr unloadhunk
  235.  
  236.     lea tempspace(a5),a0
  237.     move.l #"BODY",d0
  238.     bsr findhunk
  239.     beq .popa
  240.     movem.l (sp)+,d0-d2
  241.     bra .notiff
  242. .popa
  243.     movem.l (sp)+,d0-d2
  244.     
  245.     ;A0 = Body, D0 = Width, D1 = Height D2 = Compression type.
  246.     
  247.     move.w d0,d3
  248.     lsr.w #3,d3 ;(/8)
  249.     add.w #1,d3
  250.     move.w d3,d4
  251.     ext.l d4
  252.     mulu d1,d4
  253.     move.l d4,d7
  254.     move.l d0,d5
  255.     mulu bitplanes(a5),d7
  256.     move.l exec(a5),a6
  257.     move.l d7,d0
  258.     move.l d7,temppicsize(a5)
  259.     move.w d2,d7
  260.     move.l d1,d6
  261.     moveq.l #0,d1
  262.     move.l a0,a4
  263.     jsr -198(a6)
  264.     tst.l d0
  265.     beq .nomemscr
  266.     move.l d0,temppicadr(a5)
  267.     
  268.     move.l a4,a0    ;source
  269.     move.l d0,a1    ;dest
  270.     move.l d5,d0    ;width (pixels)
  271.     move.l d6,d1    ;height (lines)
  272.     move.b d7,d2    ;type of compression (byte)
  273.     move.w bitplanes(a5),d3    ;bitplanes
  274.     move.l d5,-(sp)
  275.     move.l d6,-(sp)
  276.     bsr convilbm
  277.  
  278.     
  279.     bsr unloadhunk
  280.     bsr closefile
  281.  
  282.     move.l (sp)+,d6            ;height source
  283.     move.l (sp)+,d5            ;width source
  284.     lsr.w #3,d5
  285.     move.l d6,d7
  286.     mulu d5,d7            ;planesize
  287.     move.l temppicadr(a5),a0    ;source
  288.     move.w blockwidth(a5),d3    ;width
  289.     move.w blockheight(a5),d4    ;height
  290.  
  291.     move.l currentblockadr(a5),a1
  292.     lea block_gfx(a1),a1        ;*** Change block start here ***
  293.     move.l a0,a2
  294.     sub.w d3,d5            ;offset
  295. ;    subq #1,d5
  296.     sub.w #1,d4
  297.     move.w bitplanes(a5),d2
  298.     subq #1,d2
  299.     subq #1,d3
  300. .cb1    move.w d4,d1        ;bitplanes
  301.  
  302. .cb2    move.w d3,d6        ;width
  303. .cb3    move.b (a0)+,(a1)+    
  304.     dbra d6,.cb3
  305.     lea (a0,d5.w),a0    ;next line
  306.     dbra d1,.cb2
  307.     lea (a2,d7.w),a2
  308.     move.l a2,a0
  309.     dbra d2,.cb1
  310.  
  311.     move.l temppicadr(a5),a1
  312.     move.l temppicsize(a5),d0    ;recover screen mem.
  313.     move.l exec(a5),a6
  314.     jsr -210(a6)
  315.  
  316.     lea tblockloaded,a0
  317.     bsr plotmess
  318.     bsr readkey
  319. .exit
  320.     bsr scrfront
  321.     rts
  322. .exit2    lea tcantlb,a0
  323.     bsr plotmess
  324.     bsr readkey
  325.     bra .exit
  326. .notiff    lea tnotiffb,a0
  327.     bsr plotmess
  328.     bsr readkey
  329.     bra .exit
  330. .wrongbp lea txtnebp,a0
  331.     bsr plotmess
  332.     bsr readkey
  333.     bsr unloadhunk
  334.     bsr closefile
  335.     bra .exit
  336. .wrongdims lea txtwrongdims,a0
  337. .same    bsr plotmess
  338.     bsr readkey
  339.     bsr unloadhunk
  340.     bsr closefile
  341.     bra .exit
  342.     rts
  343. .nomemscr lea txtnomemscr,a0
  344.     bra .same
  345. g_blockchoose
  346.     rts
  347.  
  348. convilbm: ;convert ilbm to normal. D0 = width (pixels), d1 = height
  349.       ;d2 = compression type. d3 = bitplanes. A0 = source A1 = dest.
  350.  
  351.     tst.b d2
  352.     bne .compressionon
  353.     lea $dff180,a4
  354.     sub.w #1,d0
  355.     
  356.     lsr.w #3,d0
  357.     add.w #1,d0
  358.     moveq.l #0,d6
  359.     move.w d0,d6
  360.     mulu d1,d6    ;planesize
  361.     move.l d6,d7
  362.     mulu d3,d7    ;total size
  363.     sub.w #1,d7
  364.     subq #1,d3    ;bitplanes
  365.     subq #1,d1    ;height
  366. .lc    move.w d3,d2    ;bitplanes
  367. .lb    move.w d0,d4    ;width
  368.     subq #1,d4
  369. .la    moveq.l #0,d5
  370.     move.w d2,d5
  371.     mulu d6,d5    ;planesize * bitplanes
  372.     move.l d6,a2
  373.     moveq.l #0,d6
  374.     move.w d1,d6    ;height
  375.     mulu d0,d6    ;width * height
  376.     add.l d6,d5    ;planesize*bitplanes+width*height
  377.     add.l d4,d5    ;above + width
  378.     move.l d7,d6
  379.     sub.l d5,d6
  380.     move.w d6,(a4)
  381.     move.b (a0)+,(a1,d6.l)
  382.     move.l a2,d6
  383.     dbra d4,.la
  384.     
  385.     move.l a0,d5
  386.     add.l #1,d5
  387.     and.l #-2,d5
  388.     move.l d5,a0
  389.     
  390.     dbra d2,.lb
  391.     dbra d1,.lc
  392.     rts
  393. .compressionon
  394.  
  395.     lsr.w #3,d0    ;/8
  396.     moveq.l #0,d7
  397.     move.w d0,d7
  398.     mulu d1,d7    ;plane size
  399.     subq #1,d3    ;bitplanes
  400.     subq #1,d1    ;height
  401.     subq #1,d0    ;width
  402. .rerunloop
  403.     move.w d3,d2
  404.     move.l a1,a3
  405. .bitplanes
  406.  
  407.     move.l a3,a4
  408.     move.w d0,d6
  409.     bsr loopreadline
  410.     lea (a3,d7.l),a3
  411.     dbra d2,.bitplanes
  412.     lea 1(a1,d0.w),a1
  413.     dbra d1,.rerunloop
  414.     rts
  415. loopreadline: *Used for Iff Extraction. D6 = Width. A0 = Source A4 = Dest
  416.  
  417.         clr.l    d5
  418.         move.b    (a0)+,d5
  419.         bpl.s    literalcopy
  420.  
  421. duplicatenext    cmp.b    #128,d5
  422.         bne.s    normduplicate
  423.  
  424. skipbyte        clr.b    (a4)+
  425.         subq.b    #1,d6
  426.         bpl.s    loopreadline
  427.         rts
  428.  
  429. normduplicate    neg.b    d5
  430.         move.b    (a0)+,d4
  431. loopduplicate    move.b    d4,(a4)+
  432.         subq.b    #1,d6
  433.         dbmi    d5,loopduplicate
  434.         tst.b    d6
  435.         bpl.s    loopreadline
  436.         rts
  437.  
  438. literalcopy    sub.b    d5,d6
  439.         subq.b    #1,d6
  440. loopliteralcopy    move.b    (a0)+,(a4)+
  441.         dbf    d5,loopliteralcopy
  442.         tst.b    d6
  443.         bpl.s    loopreadline
  444.         rts
  445.  
  446.  
  447.     include map.sub
  448.  
  449.  
  450.  
  451.     include map.text
  452.  
  453.  
  454.     even
  455.  
  456.     section chipdata,data_c
  457.  
  458. gad_52_31:    incbin gadgets_52*31.bm
  459. gad_199_27:    incbin gadget_199*27.bm
  460. gad_74_18:    incbin gadget_74*18.bm
  461. gad_90_30:    incbin gadget_90*30.bm
  462. gad_16_16:    incbin gadget_16*16.bm
  463. gad_up:        incbin gadget_up.bm
  464. gad_down:    incbin gadget_down.bm
  465.  
  466.     section vars,bss
  467.  
  468.  
  469. exec:         rs.l 1
  470. keybuff:    rs.l 1
  471. bye:        rs.l 1
  472. lvlsp1:        rs.l 1    ;offset to special 1 (.b)
  473. lvlsp2:        rs.l 1    ;offset to special 2 (.b)
  474. lvlsize:    rs.l 1    ;level size
  475. blockbase:    rs.l 1
  476. actualbp:    rs.w 1
  477. screenhd:    rs.l 1
  478. currentopen:    rs.l 1
  479. lock:        rs.l 1
  480. viewport:    rs.l 1
  481. bp1:        rs.l 1
  482. bp2:        rs.l 1
  483. bp3:        rs.l 1    ;must be kept together
  484. bp4:        rs.l 1
  485. bp5:        rs.l 1
  486. textsize:    rs.l 1
  487. exitbit:    rs.w 1
  488. userport:    rs.l 1
  489. olddir:        rs.l 1
  490. mousex:        rs.w 1
  491. palspace:    rs.w 1
  492. palcolours:    rs.w 1
  493. mousey:        rs.w 1
  494. rastport:    rs.l 1
  495. textbase:    rs.l 1
  496. currentcolour:    rs.w 1
  497. currentblock:    rs.w 1
  498. currentblockadr: rs.l 1
  499. currentgad:    rs.l 1
  500. lvlbase:    rs.l 1
  501. currentlevel:    rs.w 1
  502. windowtype:    rs.w 1
  503. chipblockbase:    rs.l 1
  504. eb_dx: rs.w 1
  505. eb_dy: rs.w 1
  506. blockpixelwidth: rs.w 1
  507. chipblockbasesize: rs.l 1
  508. numberoflevels: rs.w 1
  509. hunksize:    rs.l 1
  510. numberofeorlongs: rs.w 1
  511. eorstrta: rs.l 1
  512. eorstrtb: rs.l 1
  513. eormida: rs.l 1
  514. eormidb: rs.l 1
  515. eorenda: rs.l 1
  516. eorendb: rs.l 1
  517. temppicadr: rs.l 1
  518. temppicsize: rs.l 1
  519. hunkbase:    rs.l 1
  520. choose_type:    rs.w 1
  521. choose_name:    rs.l 1
  522. choose_num:    rs.w 1
  523. blockeditactualx: rs.w 1
  524. blockeditactualy: rs.w 1
  525. windowhd:    rs.l 1
  526. ucprlist:    rs.l 1
  527. lvlwidth:    rs.w 1
  528. blocksize:    rs.w 1  ;size of a block
  529. blockmask:    rs.w 1    ;offset to block mask
  530. lvlheight:    rs.w 1
  531. numberofblocks: rs.w 1
  532. blockwidth:    rs.w 1
  533. blockheight:    rs.w 1
  534. bitplanes:    rs.w 1
  535. theprefs:    rs.b 100
  536. tempspace:    rs.b 50
  537. dirname:    rs.b 128
  538. _evar         rs.w 1
  539. variables: dcb.b (_evar),0
  540.  
  541.     
  542.     end    
  543.  
  544.