home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 3 / CD_Magazyn_EXEC_nr_3.iso / Recent / game / wb / Klotz.lha / Klotz / src / Stein.asm < prev    next >
Assembly Source File  |  1998-03-09  |  10KB  |  559 lines

  1. *
  2. *   $VER: Stein 1.0  (2.5.97)  I felt like doing it.
  3. *      Stein 0.17 (30.8.95) Neues Datenformat
  4. *      Stein 0.16 (15.9.93) Heut'ist (nicht mehr) Vollmond.
  5. *                 Heut'ist schon(nicht mehr) Neumond.
  6.  
  7. * Einige Konstanten
  8. SPINUP        = 2
  9. SPINDOWN    = 0
  10. SPINLEFT    = 1
  11. SPINRIGHT   = 3
  12.  
  13. CheckPosMove
  14. *
  15. *   =>    a0  :    Stein
  16. *    d0  :    Spalte
  17. *    d1  :    Zeile
  18. *    d2  :    Drehung
  19. *   <=    d0  :    Fehler = -1
  20. *
  21.     push    a0-a2/d1-d7
  22.     bsr     FetchSImage
  23.     cmpi.b  #1,d0
  24.     blt.s   .ohNo
  25.     move.b  d0,d3
  26.     add.b   2(a2),d3
  27.     subq.b  #1,d3
  28.     cmpi.b  #10,d3
  29.     bgt.s   .ohNo
  30.  
  31.     move.b  d1,d3
  32.     sub.b   3(a2),d3
  33.     addq.b  #1,d3
  34.     cmpi.b  #1,d3
  35.     blt.s   .ohNo
  36.  
  37.     bsr.s   CheckFeld
  38.     tst.b   d0
  39.     bne.s   .ohNo
  40.     moveq   #0,d0
  41. .exit
  42.     pop     a0-a2/d1-d7
  43.     rts
  44. .ohNo
  45.     moveq   #-1,d0
  46.     bra.s   .exit
  47.  
  48. CheckPosDrop
  49. *
  50. *   =>    a0  :    Stein
  51. *    d0  :    Spalte
  52. *    d1  :    Zeile
  53. *    d2  :    Drehung
  54. *   <=    d0  :    Fehler = -1
  55. *
  56.     push    a0-a2/d1-d7
  57.     bsr     FetchSImage
  58.     move.w  d0,d4
  59.     move.w  d1,d5
  60.     move.b  d1,d3
  61.     sub.b   3(a2),d3
  62.     addq.b  #1,d3
  63.     cmpi.b  #1,d3
  64.     blt.s   .ohNo
  65.  
  66.     bsr.s   CheckFeld
  67.     bne.s   .ohNo
  68.     moveq   #0,d0
  69. .exit
  70.     pop     a0-a2/d1-d7
  71.     rts
  72. .ohNo
  73.     moveq   #-1,d0
  74.     bra.s   .exit
  75.  
  76. CheckFeld
  77. *   Überprüfe, ob Feld belegt
  78. *   =>    a0  :    SteinFeld
  79. *    a2  :    SteinImage
  80. *    d0,d1:    Spalte/Zeile
  81. *
  82. *   <=    d0  :    -1 wenn belegt
  83.     push    a0-a2/d1-d7
  84.     move.b  (a0),d7
  85.     move.w  d0,d5
  86.     move.w  d1,d6
  87.     moveq   #0,d4
  88. .neueZeile
  89.     moveq   #0,d3
  90. .neuerPunkt
  91.     rol.b   #1,d7
  92.     bcc.s   .keinPunkt
  93.     move.w  d5,d0
  94.     add.w   d3,d0
  95.     move.w  d6,d1
  96.     sub.w   d4,d1
  97.  
  98.     bsr.s   GetFeld
  99.     tst.b   d0
  100.     bne.s   .ohNo
  101. .keinPunkt
  102.     addq.w  #1,d3
  103.     cmp.b   2(a2),d3
  104.     blt.s   .neuerPunkt
  105.     addq.w  #1,d4
  106.     cmp.b   3(a2),d4
  107.     blt.s   .neueZeile
  108.  
  109.     moveq   #0,d0
  110. .exit
  111.     pop     a0-a2/d1-d7
  112.     rts
  113. .ohNo
  114.     moveq   #1,d0
  115.     bra.s   .exit
  116.  
  117. SetFeld
  118. *  Belege Feld
  119. *
  120. *   =>    a0  :    Stein
  121. *    d0  :    Spalte
  122. *    d1  :    Zeile
  123. *    d2  :    Drehung
  124.     push    all
  125.     bsr     FetchSImage
  126.     move.w  d0,d5
  127.     move.w  d1,d6
  128.     move.b  (a0),d7
  129.     addq.b  #1,d2
  130.     moveq   #0,d4
  131. .neueZeile
  132.     moveq   #0,d3
  133. .neuerPunkt
  134.     rol.b   #1,d7
  135.     bcc.s   .keinPunkt
  136.     move.w  d5,d0
  137.     add.w   d3,d0
  138.     move.w  d6,d1
  139.     sub.w   d4,d1
  140.     bsr.s   GetFeld
  141.     move.b  d2,(a0)
  142. .keinPunkt
  143.     addq.w  #1,d3
  144.     cmp.b   2(a2),d3
  145.     blt.s   .neuerPunkt
  146.     addq.w  #1,d4
  147.     cmp.b   3(a2),d4
  148.     blt.s   .neueZeile
  149. .exit
  150.     pop     all
  151.     rts
  152. GetFeld
  153. *   Gibt Speicherpufferposition zurück ( whaui-whaui was für'n Wort !)
  154. *   =>    d0  :    Spalte
  155. *    d1  :    Zeile
  156. *   <=    a0  :    SPP(s.o.)
  157. *    d0  :    Inhalt von SPP
  158.     push    d1-d2
  159.     moveq   #31,d2
  160.     and.l   d2,d0
  161.     and.l   d2,d1
  162.  
  163.     subq.w  #1,d0
  164.     subq.w  #1,d1
  165.  
  166.     move.w  d1,d2    d1*10=d1<<3+d1+d1
  167.     lsl.w   #3,d1
  168.     add.w   d2,d1
  169.     add.w   d2,d1
  170.     add.w   d0,d1
  171.     copy.l  SpielFeld,a0
  172.     lea     0(a0,d1),a0
  173.     move.b  (a0),d0
  174.     ext.w   d0
  175.     pop     d1-d2
  176.     rts
  177. ; wie wär's mit Alloc ?    Your wish is my command.
  178.  loc.l SpielFeld
  179. *    dc.l 0
  180.  
  181. CheckLines
  182. *   Prüfe auf volle Zeilen
  183. *
  184. *   <=    d0  :    Anzahl voller Zeilen oder -1 wenn Game over
  185. *    d1  :    Bitset volle Zeilen
  186.     push    d2-d5/a0-a2
  187.     moveq   #19,d1
  188.     moveq   #1,d2
  189. .check
  190.     move.w  d2,d0
  191.     bsr.s   GetFeld
  192.     tst.b   d0
  193.     bne.s   .Line19Used
  194.     addq.b  #1,d2
  195.     cmpi.b  #10,d2
  196.     bls.s   .check
  197.  
  198.     moveq   #1,d1   Zeilenzähler
  199.     moveq   #0,d3   Zeilen voll
  200.     moveq   #0,d5   Zeilennr. ( ähnlich PlanePick) mit gesetzten Bits
  201. .doline
  202.     moveq   #1,d2   Spaltenzähler
  203. .dopunkt
  204.     move.w  d2,d0
  205.     bsr.s   GetFeld
  206.     beq.s   .nextline
  207. .nextpunkt
  208.     addq.w  #1,d2
  209.     cmpi.b  #10,d2
  210.     bls.s   .dopunkt
  211.     addq.w  #1,d3
  212.     bset    d1,d5
  213.     pea     -9(a0)
  214. .nextline
  215.     addq.w  #1,d1
  216.     cmpi.b  #18,d1
  217.     bls.s   .doline
  218.  
  219.     move.w  d3,d4
  220.     tst.b   d3
  221.     beq.s   .exit
  222.     subq.w  #1,d3
  223.     moveq   #10,d0
  224.     moveq   #18,d1
  225.     bsr.s   GetFeld
  226.     move.l  a0,a2
  227. .loop
  228.     move.l  (sp)+,a0
  229. .copyloop
  230.     move.w  10(a0),(a0)
  231.     addq.l  #2,a0
  232.     cmp.l   a2,a0
  233.     blt.s   .copyloop
  234.     dbra    d3,.loop
  235.  
  236. .exit
  237.     move.w  d4,d0
  238.     move.w  d5,d1
  239.     pop     d2-d5/a0-a2
  240.     rts
  241. .Line19Used
  242.     moveq   #-1,d4
  243.     bra     .exit
  244.  bloc FeldMatrix,200
  245. InitFeld
  246. *
  247. *   Speicher anfordern
  248. *
  249.     lea     FeldMatrix(a4),a0
  250.     reloc.l a0,SpielFeld
  251. CleanUpFeld
  252. *
  253. *   Speicher freigeben
  254. *
  255.     rts
  256. AufbauFeld
  257. *   Feldaufbau aus DatenFeld
  258. *
  259.     push    d0-d3/a0-a1
  260.     copy.l  CRastPort,a1
  261.     moveq   #1,d1
  262. .loop
  263.     moveq   #1,d3
  264. .loop2
  265.     move.w  d3,d0
  266.     bsr     GetFeld
  267.     tst.b   d0
  268.     beq.s   .clear
  269.     move.w  d0,d2
  270.     subq.w  #1,d2
  271.     move.w  d3,d0
  272.     bsr     PutKlotz
  273.     bra.s   .next2
  274. .clear
  275.     move.w  d3,d0
  276.     bsr     DelKlotz
  277. .next2
  278.     addq.w  #1,d3
  279.     cmpi.b  #10,d3
  280.     bls.s   .loop2
  281.     addq.w  #1,d1
  282.     cmpi.b  #18,d1
  283.     bls.s   .loop
  284.     pop     d0-d3/a0-a1
  285.     rts
  286.  
  287. SetStein
  288. *   Setze Stein
  289. *   =>    a0 : Stein
  290. *    d0 : Spalte
  291. *    d1 : Zeile
  292. *    d2 : Drehung
  293.     push    d0-d7/a0-a3
  294.     lea     PutKlotz(pc),a3
  295.     bra.s   SetClearStein
  296. ClearStein
  297. *   Lösche Stein (vielleicht noch gemeinsame U-Routine für Set & Clear ?)
  298. *   =>    a0 : Stein
  299. *    d0 : Spalte
  300. *    d1 : Zeile
  301. *    d2 : Drehung
  302.     push    d0-d7/a0-a3
  303.     lea     DelKlotz(pc),a3
  304. SetClearStein
  305. * hier ist sie (mit zwei Jahren Verspätung )
  306.     bsr     FetchSImage
  307.     move.b  (a0),d7
  308.     move.w  d0,d5
  309.     move.w  d1,d6
  310.     moveq   #0,d4
  311. .neueZeile
  312.     moveq   #0,d3
  313. .neuerPunkt
  314. *    rol.b   #1,d7
  315.     add.b   d7,d7
  316.     bcc.s   .keinPunkt
  317.     move.w  d5,d0
  318.     add.w   d3,d0
  319.     move.w  d6,d1
  320.     sub.w   d4,d1
  321.  
  322.     cmpi.b  #1,d1
  323.     blt.s   .keinPunkt
  324.     cmpi.b  #18,d1
  325.     bgt.s   .keinPunkt
  326.  
  327.     copy.l  CRastPort,a1
  328.     jsr     (a3)
  329. .keinPunkt
  330.     addq.w  #1,d3
  331.     cmp.b   2(a2),d3
  332.     blt.s   .neuerPunkt
  333.     addq.w  #1,d4
  334.     cmp.b   3(a2),d4
  335.     blt.s   .neueZeile
  336. .ohNo
  337.     pop     d0-d7/a0-a3
  338.     rts
  339.  
  340. SetNXStein
  341. *  Next-Feld Verwaltung
  342. *   =>    a0 : Stein
  343. *
  344.     push    all
  345.     move.l  a0,a2
  346.     lea     NXBorders,a1
  347.     move.w  (a1)+,d0
  348.     move.w  (a1)+,d1
  349.     move.w  (a1)+,d2
  350.     move.w  (a1)+,d3
  351. *    copy.l  TSize,d5
  352. *    add.l   d5,d1
  353. *    add.l   d5,d3
  354.     GZZ
  355.     GZZ2
  356.     moveq   #BOX_RECESSED,d4
  357.     copy.l  CRastPort,a1
  358.     bsr     OSzweinullBorder            ; erst löschen
  359.     move.l  a2,a0
  360.     moveq   #0,d0
  361.     moveq   #3,d1
  362.     moveq   #SPINDOWN,d2
  363.     bsr     FetchSImage
  364.     move.b  (a0),d7
  365.     move.w  d0,d5
  366.     move.w  d1,d6
  367.     moveq   #0,d4
  368. .neueZeile
  369.     moveq   #0,d3
  370. .neuerPunkt
  371.     rol.b   #1,d7
  372.     bcc     .keinPunkt
  373.     move.w  d5,d0
  374.     add.w   d3,d0
  375.     move.w  d6,d1
  376.     sub.w   d4,d1
  377.  
  378.     copy.l  CRastPort,a1
  379.     bsr     PutNXKlotz
  380. .keinPunkt
  381.     addq.w  #1,d3
  382.     cmp.b   2(a2),d3
  383.     blt     .neuerPunkt
  384.     addq.w  #1,d4
  385.     cmp.b   3(a2),d4
  386.     blt     .neueZeile
  387.  
  388.     pop     all
  389.     rts
  390. FetchSImage
  391. *   holt SteinImage
  392. *   =>    a0  :    Stein
  393. *    d0,d1,d2 : s.o.
  394. *   <=    a0  :    Steinfeld
  395. *    a2  :    SImage
  396. *    d0,d1:    +Offset
  397. *    d2  :    Farbe
  398.     andi.w  #3,d2
  399.     add.w   d2,d2
  400.     move.w  0(a0,d2),d2         SteinImage
  401.     lea     0(a0,d2),a2
  402.     move.b  8(a0),d2            Neue Farbe
  403.     tst.b   IsBW(a4)
  404.     beq.s   .notoneplane
  405.     andi.b   #1,d2
  406. .notoneplane
  407.     lea     4(a2),a0
  408.     add.b   0(a2),d0        Left addieren
  409.     ext.w   d0
  410.     sub.b   1(a2),d1        Top  subtrahieren
  411.     ext.w   d1
  412.     rts
  413. GetSteinAdr
  414. *   Stein-Adresse
  415. *   =>    d0  :    Steinnummer 0..6
  416. *   <=    a0,d0:     Stein-Struktur
  417. *
  418.     push    d1
  419.     moveq   #7,d1
  420.     and.l   d1,d0
  421.     move.l  d0,d1
  422.     lsl.l   #3,d0
  423.     add.l   d1,d0
  424.     add.l   d1,d0
  425.     lea     Steine(pc,d0),a0
  426.     move.l  a0,d0
  427.     pop     d1
  428.     rts
  429. * Daten
  430. Steine
  431. *
  432. *   Struct Stein {
  433. *    PTR  SteinImage[4] relativer Ptr (zum Anfang der Struktur)
  434. *    BYTE Farbe }
  435. *
  436. *
  437. *   SteinImage0: unten
  438. *          1: links
  439. *          2: oben
  440. *          3: rechts
  441. *   Struct SteinImage { UBYTE Left,Top,width,height; BITS Steinfeld[width,height] }
  442. *
  443.  
  444. *Klotz
  445. Stein0
  446.     dc.w Image00-Stein0
  447.     dc.w Image00-Stein0
  448.     dc.w Image00-Stein0
  449.     dc.w Image00-Stein0
  450.     dc.b GrauKLOTZ
  451.     even
  452. * Stange
  453. Stein1
  454.     dc.w Image10-Stein1
  455.     dc.w Image11-Stein1
  456.     dc.w Image10-Stein1
  457.     dc.w Image11-Stein1
  458.     dc.b GrauBlauKLOTZ
  459.     even
  460. * T-Stück
  461. Stein2
  462.     dc.w Image20-Stein2
  463.     dc.w Image21-Stein2
  464.     dc.w Image22-Stein2
  465.     dc.w Image23-Stein2
  466.     dc.b BlauKLOTZ
  467.     even
  468. * L-Stück
  469. Stein3
  470.     dc.w Image30-Stein3
  471.     dc.w Image31-Stein3
  472.     dc.w Image32-Stein3
  473.     dc.w Image33-Stein3
  474.     dc.b SchwarzBlauKLOTZ
  475.     even
  476. * L-invers-Stück
  477. Stein4
  478.     dc.w Image40-Stein4
  479.     dc.w Image41-Stein4
  480.     dc.w Image42-Stein4
  481.     dc.w Image43-Stein4
  482.     dc.b WeissBlauKLOTZ
  483.     even
  484. * Z-Stück
  485. Stein5
  486.     dc.w Image50-Stein5
  487.     dc.w Image51-Stein5
  488.     dc.w Image50-Stein5
  489.     dc.w Image51-Stein5
  490.     dc.b SchwarzGrauKLOTZ
  491.     even
  492. * Z-invers-Stück
  493. Stein6
  494.     dc.w Image60-Stein6
  495.     dc.w Image61-Stein6
  496.     dc.w Image60-Stein6
  497.     dc.w Image61-Stein6
  498.     dc.b WeissGrauKLOTZ
  499.     even
  500. Image00
  501.     dc.b 1,1,2,2
  502.     dc.b %11110000
  503. Image10
  504.     dc.b 0,1,4,1
  505.     dc.b %11110000
  506. Image11
  507.     dc.b 1,0,1,4
  508.     dc.b %11110000
  509. Image20
  510.     dc.b 0,1,3,2
  511.     dc.b %11101000
  512. Image21
  513.     dc.b 0,0,2,3
  514.     dc.b %01110100
  515. Image22
  516.     dc.b 0,0,3,2
  517.     dc.b %01011100
  518. Image23
  519.     dc.b 1,0,2,3
  520.     dc.b %10111000
  521. Image30
  522.     dc.b 0,1,3,2
  523.     dc.b %11110000
  524. Image31
  525.     dc.b 1,0,2,3
  526.     dc.b %11010100
  527. Image32
  528.     dc.b 0,0,3,2
  529.     dc.b %00111100
  530. Image33
  531.     dc.b 0,0,2,3
  532.     dc.b %10101100
  533. Image40
  534.     dc.b 0,1,3,2
  535.     dc.b %11100100
  536. Image41
  537.     dc.b 0,0,2,3
  538.     dc.b %01011100
  539. Image42
  540.     dc.b 0,0,3,2
  541.     dc.b %10011100
  542. Image43
  543.     dc.b 1,0,2,3
  544.     dc.b %11101000
  545. Image50
  546.     dc.b 0,1,3,2
  547.     dc.b %11001100
  548. Image51
  549.     dc.b 0,1,2,3
  550.     dc.b %01111000
  551. Image60
  552.     dc.b 0,1,3,2
  553.     dc.b %01111000
  554. Image61
  555.     dc.b 0,0,2,3
  556.     dc.b %10110100
  557.  
  558.     EVEN
  559.