home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 92 / asm / source / fargo / tron.asm < prev   
Encoding:
Assembly Source File  |  2001-07-01  |  8.1 KB  |  492 lines

  1.     include    "tios.h"
  2.     include    "flib.h"
  3.     xdef    _main
  4.     xdef    _comment
  5.  
  6. on        macro            ;do black pixels
  7.     move.w    \1,-(a7)
  8.     move.w    \2,-(a7)
  9.     jsr    flib::pixel_on
  10.     lea    4(a7),a7
  11.     move.w    \1,-(a7)
  12.     move.w    \2,-(a7)
  13.     add.w    #1,\1
  14.     add.w    #1,\2
  15.     move.w    \1,-(a7)
  16.     move.w    \2,-(a7)
  17.     sub.w    #2,\1
  18.     sub.w    #2,\2
  19.     move.w    \1,-(a7)
  20.     move.w    \2,-(a7)
  21.     jsr    flib::frame_rect
  22.     lea    12(a7),a7
  23.     add.w    #1,\1
  24.     add.w    #1,\2
  25.     endm
  26.  
  27. fonts        macro            ;print text
  28.     move.w    \1,-(a7)
  29.     jsr    tios::FontSetSys
  30.     lea    2(a7),a7
  31.     move.w    \2,-(a7)
  32.     pea    \5(PC)
  33.     move.w    \4,-(a7)
  34.     move.w    \3,-(a7)
  35.     jsr    tios::DrawStrXY
  36.     lea    10(a7),a7
  37.     endm
  38.  
  39. shownum:moveq    #2,d1
  40.     lea    strbuf(PC),a0
  41.     adda.l    d1,a0
  42.     clr.b    (a0)
  43.     subq.b    #1,d1
  44. num_loop:
  45.     divu    #10,d0
  46.     move.l    d0,d2
  47.     lsr.l    #8,d2
  48.     lsr.l    #8,d2
  49.     add.b    #48,d2
  50.     move.b    d2,-(a0)
  51.     and.l    #$FFFF,d0
  52.     dbra    d1,num_loop
  53.     rts
  54.  
  55. _main:    move.w    0,sco            ;P1
  56.     move.w    0,scor            ;P2
  57.     jsr    flib::zap_screen
  58.     fonts    #1,#2,#1,#1,z1
  59.     fonts    #1,#2,#20,#12,z2
  60.     fonts    #1,#2,#20,#22,z3
  61.     fonts    #2,#0,#0,#50,z4
  62.     fonts    #2,#0,#0,#60,z5
  63.     fonts    #1,#1,#60,#80,z6
  64.     fonts    #1,#1,#60,#90,z7
  65.     fonts    #1,#1,#60,#100,z8
  66.     jsr    flib::idle_loop
  67.     cmp.b    #13,d0
  68.     beq    main
  69.     cmp.b    #264,d0
  70.     beq    fin
  71.     cmp.w    #$10C,d0
  72.     beq    option
  73.     jmp    _main
  74.  
  75. main:    clr.b    fla
  76.     clr.b    fl
  77.     clr.b    tes
  78.  
  79.     jsr    flib::zap_screen
  80.     move.w  #119,-(a7)
  81.     move.w  #239,-(a7)
  82.     move.w  #1,-(a7)
  83.     move.w  #16,-(a7)
  84.     jsr     flib::frame_rect
  85.     lea     8(a7),a7
  86.     pea    _comment(pc)
  87.     jsr    tios::ST_showHelp
  88.     lea    4(a7),a7
  89.  
  90.     move.b    #2,(dir)
  91.     move.b    #1,(zdir)
  92.  
  93.     fonts    #2,#0,#0,#0,p1
  94.     fonts    #2,#0,#0,#22,p2
  95.     fonts    #2,#0,#0,#44,nb
  96.     fonts    #2,#0,#0,#66,rd
  97.     fonts    #2,#0,#0,#88,sp
  98.     move.w    sco,d0
  99.         move.w    #11,d3
  100.         bsr    shownum
  101.     fonts    #2,#4,0,d3,strbuf
  102.     move.w    scor,d0
  103.         move.w    #33,d3
  104.         bsr    shownum
  105.     fonts    #2,#4,0,d3,strbuf
  106.  
  107.     move.w    tspee,d0
  108.         move.w    #77,d3
  109.         bsr    shownum
  110.     fonts    #2,#4,0,d3,strbuf
  111.     move.w    tspeed,d0
  112.         move.w    #99,d3
  113.         bsr    shownum
  114.     fonts    #2,#4,0,d3,strbuf
  115.  
  116.     move.w    #63,d3
  117.     move.w    #60,d4
  118.     move.w    #57,d5
  119.     move.w    #195,d6
  120. main_loop:
  121.     clr.b    te
  122.     tst.w    tios::kb_globals+$1C
  123.     beq    touche            ;no end
  124.     clr.w    tios::kb_globals+$1C
  125.     move.w    tios::kb_globals+$1E,d0
  126.     cmp.w    #264,d0            ;end
  127.     beq    _main
  128.  
  129. touche: move.w    d3,-(a7)        ;tests the pixel    P1
  130.     move.w    d4,-(a7)
  131.     jsr    flib::find_pixel
  132.     lea    4(a7),a7        ;reset stack ptr
  133.     btst    d0,(a0)
  134.     bne    gagne1
  135.  
  136. chance:    cmp.b    #1,te
  137.     beq    chance2
  138.     move.w    d5,-(a7)         ;tests the pixel    P2
  139.     move.w    d6,-(a7)
  140.     jsr    flib::find_pixel
  141.     lea    4(a7),a7        ;reset stack ptr
  142.     btst    d0,(a0)
  143.     bne    gagne2
  144.  
  145.     cmp.b    #1,tes
  146.     beq    chance2
  147.  
  148.     on    d3,d4            ;player1 d3=x  d4=y
  149.     on    d5,d6            ;player2 d5=x  d6=y
  150.  
  151.     move.w    d3,d7
  152.     cmp.b    #9,fl
  153.     bne    suite
  154.     add.b    #1,fla
  155.     clr.b    fl
  156.     jmp    suite1
  157.  
  158. suite:    add.b    #1,fl
  159.  
  160. suite1:    move.b    fla,d0
  161.     move.w    #55,d3
  162.     bsr    shownum
  163.     fonts    #2,#4,0,d3,strbuf
  164.     move.w    d7,d3
  165.  
  166.     move.w    #0,(bou)
  167.     move.w    tspe,d0
  168.     mulu.w    #200,d0
  169.  
  170. delay:    add.w    #1,bou            ;loop for wait
  171.     cmp.w    bou,d0            ;change delay default=10000
  172.     bne    delay
  173.  
  174.     move.w  #$FFFD,($600018)
  175.     nop
  176.     nop
  177.     nop
  178.     nop
  179.     move.b  ($60001B),d0
  180.     not.b   d0
  181.     and.b   #32,d0
  182.     cmpi.b  #32,d0
  183.     bne    touche3
  184.     move.b    #1,(zdir)
  185.  
  186. touche3:
  187.     move.w  #$FFFD,($600018)
  188.     nop
  189.     nop
  190.     nop
  191.     nop
  192.     move.b  ($60001B),d0
  193.     not.b   d0      
  194.     and.b   #128,d0
  195.     cmpi.b  #128,d0
  196.     bne    touche_cos
  197.     move.b    #2,(zdir)
  198.  
  199. touche_cos:
  200.     move.w  #$FFF7,($600018)
  201.     nop
  202.     nop
  203.     nop
  204.     nop
  205.     move.b  ($60001B),d0
  206.     not.b   d0      
  207.     and.b   #64,d0
  208.     cmpi.b  #64,d0
  209.     bne     touche8
  210.     move.b    #4,(zdir)
  211.  
  212. touche8:
  213.     move.w  #$FFDF,($600018)
  214.     nop
  215.     nop
  216.     nop
  217.     nop
  218.     move.b  ($60001B),d0
  219.     not.b   d0      
  220.     and.b   #64,d0
  221.     cmpi.b  #64,d0
  222.     bne     touche_f2
  223.     move.b    #3,(zdir)
  224.  
  225. touche_f2:
  226.     move.w  #$FFEF,($600018)
  227.     nop
  228.     nop
  229.     nop
  230.     nop
  231.     move.b  ($60001B),d0
  232.     not.b   d0
  233.     and.b   #16,d0
  234.     cmpi.b  #16,d0
  235.     bne     touche_f6
  236.     move.b    #1,(dir)
  237.  
  238. touche_f6:
  239.     move.w  #$FFDF,($600018)
  240.     nop
  241.     nop
  242.     nop
  243.     nop
  244.     move.b  ($60001B),d0
  245.     not.b   d0      
  246.     and.b   #16,d0
  247.     cmpi.b  #16,d0
  248.     bne     touchez
  249.     move.b    #2,(dir)
  250.  
  251. touchez:
  252.     move.w  #$FFFD,($600018)
  253.     nop
  254.     nop
  255.     nop
  256.     nop
  257.     move.b  ($60001B),d0
  258.     not.b   d0      
  259.     and.b   #2,d0
  260.     cmpi.b  #2,d0
  261.     bne     touchew
  262.     move.b    #4,(dir)
  263.  
  264. touchew:
  265.     move.w  #$FFFD,($600018)
  266.     nop
  267.     nop
  268.     nop
  269.     nop
  270.     move.b  ($60001B),d0
  271.     not.b   d0      
  272.     and.b   #8,d0
  273.     cmpi.b  #8,d0
  274.     bne     continu
  275.     move.b    #3,(dir)
  276.  
  277. continu:
  278.     move.b    #1,te
  279.     cmp.b    #1,(dir)
  280.     beq    dir1
  281.     cmp.b    #2,(dir)
  282.     beq    dir2
  283.     cmp.b    #3,(dir)
  284.     beq    dir3
  285.     cmp.w    #$75,d3
  286.     beq    gagne1
  287.     add.b    #3,d3
  288.     jmp    chance2
  289.  
  290. dir1:    cmp.w    #$12,d4
  291.     beq    gagne1
  292.     sub.b    #3,d4            ;substracte y of p1
  293.     jmp    chance2
  294.  
  295. dir2:    cmp.w    #$ED,d4
  296.     beq    gagne1
  297.     add.b    #3,d4
  298.     jmp    chance2
  299.  
  300. dir3:    cmp.w    #03,d3
  301.     beq    gagne1
  302.     sub.b    #3,d3            ;substracte x of p1
  303.  
  304. chance2:
  305.     cmp.b    #1,(zdir)
  306.     beq    zdir1
  307.     cmp.b    #2,(zdir)
  308.     beq    zdir2
  309.     cmp.b    #3,(zdir)
  310.     beq    zdir3
  311.     cmp.w    #$75,d5
  312.     beq    gagne2
  313.     add.b    #3,d5
  314.     jmp    retour
  315.  
  316. zdir1:    cmp.w    #$12,d6
  317.     beq    gagne2
  318.     sub.b    #3,d6            ;substracte y of p2
  319.     jmp    retour
  320.  
  321. zdir2:    cmp.w    #$ED,d6
  322.     beq    gagne2
  323.     add.b    #3,d6
  324.     jmp    retour
  325.  
  326. zdir3:    cmp.w    #03,d5
  327.     beq    gagne2
  328.     sub.b    #3,d5            ;substracte x of p2
  329.  
  330. retour:    cmp.b    #1,tes
  331.     beq    stope
  332.     jmp    main_loop
  333.  
  334. gagne1:    move.w    tspee,d7        ;+1 α P2
  335.     cmp.w    scor,d7
  336.     beq    win1            ;end and winner    P1
  337.     add.w    #1,scor
  338.     move.b    #1,tes
  339.     fonts    #0,#0,#27,#122,z18
  340.     jmp    chance
  341.  
  342. gagne2:    move.w    tspee,d7        ;+1 α P1
  343.     cmp.w    sco,d7
  344.     beq    win2            ;end and winner    P2
  345.     add.w    #1,sco
  346.     fonts    #0,#0,#185,#122,z19
  347.     jmp    stope
  348.  
  349. stope:    move.w    sco,d0
  350.     move.w    #11,d3
  351.     bsr    shownum
  352.     fonts    #2,#4,0,d3,strbuf
  353.     move.w    scor,d0
  354.     move.w    #33,d3
  355.     bsr    shownum
  356.     fonts    #2,#4,0,d3,strbuf
  357.     jsr    flib::idle_loop
  358.     cmp.w    #13,d0
  359.     beq    main
  360.     cmp.w    #261,d0
  361.     beq    pla
  362.     cmp.w    #264,d0
  363.     beq    _main
  364.     jmp    stope
  365.  
  366. win2:    jsr    flib::zap_screen    ;P1
  367.     fonts    #2,#0,#30,#50,z15
  368.     fonts    #1,#2,#50,#90,z14
  369.     jsr    flib::idle_loop
  370.     cmp.b    #13,d0
  371.     beq    enter3
  372.     jmp    win2
  373.     
  374. win1:    move.w    sco,d1
  375.     cmp.w    tspee,d1
  376.     beq    win3
  377.     jsr    flib::zap_screen
  378.     fonts    #2,#0,#30,#50,z16    ;P2
  379.     fonts    #1,#2,#50,#90,z14
  380.     jsr    flib::idle_loop
  381.     cmp.b    #13,d0
  382.     beq    enter3
  383.     jmp    win1
  384.  
  385. win3:    jsr    flib::zap_screen
  386.     fonts    #2,#0,#30,#50,z17    ;P1&P2
  387.     fonts    #1,#2,#50,#90,z14
  388.     jsr    flib::idle_loop
  389.     cmp.b    #13,d0
  390.     beq    enter3
  391.     jmp    win3
  392.  
  393. pla:    add.w    #1,scor
  394.     jmp    stope
  395.  
  396. enter3:    jmp    _main
  397.  
  398. option:    jsr    flib::zap_screen
  399.     fonts    #1,#2,#10,#10,z9
  400.     fonts    #1,#2,#10,#30,z10
  401.     fonts    #1,#2,#10,#40,z11
  402.     fonts    #1,#2,#10,#50,z12
  403.     fonts    #1,#2,#10,#60,z13
  404.     fonts    #1,#2,#60,#110,z14
  405.     fonts    #2,#4,#10,#80,opt
  406.     fonts    #2,#4,#10,#90,opt2
  407.  
  408. bm:    move.w    tspee,d0
  409.         move.w    #80,d3
  410.         bsr    shownum
  411.     fonts    #2,#4,#67,d3,strbuf
  412.     jsr    flib::idle_loop
  413.     cmp.w    #$154,d0
  414.     bne    bm2
  415.     add.w    #1,(tspee)
  416.  
  417. bm2:    cmp.w    #$151,d0
  418.     bne    bm3
  419.     sub.w    #1,(tspee)
  420.  
  421. bm3:    cmp.w    #$D,d0
  422.     beq    am
  423.     bra    bm
  424.  
  425. am:    move.w    tspeed,d0
  426.         move.w    #90,d3
  427.         bsr    shownum
  428.     fonts    #2,#4,#67,d3,strbuf
  429.     jsr    flib::idle_loop
  430.     cmp.w    #$154,d0
  431.     bne    am2
  432.     add.w    #1,(tspeed)
  433.  
  434. am2:    cmp.w    #$151,d0
  435.     bne    am3
  436.     sub.w    #1,(tspeed)
  437.  
  438. am3:    cmp.w    #$D,d0
  439.     beq    finam
  440.     bra    am
  441.  
  442. finam:    move.w    #100,d7
  443.     sub.w    tspeed,d7
  444.     move.w    d7,tspe
  445.     bra    _main
  446.  
  447. fin:    rts
  448.  
  449. dir    dc.b    2
  450. zdir    dc.b    1
  451. bou    dc.w    0
  452. z4    dc.b    16,"Bienvenue dans le monde TRON",16,0
  453. z5    dc.b    16," Welcome in the world TRON  ",16,0
  454. z6    dc.b    "<ENTER> - Play TRON",0
  455. z1    dc.b    "David H√",0
  456. z2    dc.b    "((((alfred02@club-internet.fr))))",0
  457. z3    dc.b    " ))))ICQ-----10872061----ICQ((((",0
  458. z7    dc.b    "<F1>    - Help and Option",0
  459. z8    dc.b    "<ESC>   - Exit",0
  460. p1    dc.b    "P1",0
  461. p2    dc.b    "P2",0
  462. nb    dc.b    "NB",0
  463. sp    dc.b    "SP",0
  464. rd    dc.b    "RD",0
  465. z9    dc.b    "          PLAYER 1    PLAYER2",0
  466. z10    dc.b    "UP     :    <F6>        <1>",0
  467. z11    dc.b    "DOWN   :    <F2>        <3>",0
  468. z12    dc.b    "LEFT   :    <W>         <8>",0
  469. z13    dc.b    "RIGHT  :    <Z>        <COS>",0
  470. z14    dc.b    "<ENTER> - Main Menu",0
  471. z15    dc.b    "  WINNER : PLAYER 1  ",0
  472. z16    dc.b    "  WINNER : PLAYER 2  ",0
  473. z17    dc.b    "       DRAW !!!!     ",0
  474. z18    dc.b    "PLAYER 1",0
  475. z19    dc.b    "PLAYER 2",0
  476. scor    dc.w    0
  477. sco    dc.w    0
  478. strbuf    dc.l    0
  479. opt    dc.b    "Round ",17,"  ",18,0
  480. opt2    dc.b    "Speed ",17,"  ",18,0
  481. tspee    dc.w    9
  482. tspeed    dc.w    50
  483. tspe    dc.w    50
  484. fla    dc.b    0
  485. fl    dc.b    0
  486. tes    dc.b    0
  487. te    dc.b    0
  488.  
  489. _comment:
  490.     dc.b    "                                         Tron by David H√ 1998",0
  491.  
  492.     end