home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Blitter / RandomPlot.s < prev    next >
Encoding:
Text File  |  1997-02-16  |  3.0 KB  |  130 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Random Plot
  3. ;-----------
  4. ;This is a graphical demonstration of the Random() functions.  The default
  5. ;is to use FastRandom, but you can change it to SlowRandom if you look
  6. ;below.
  7. ;
  8. ;LMB exits.
  9.  
  10.     INCDIR    "INCLUDES:"
  11.     INCLUDE    "exec/exec_lib.i"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i"
  14.  
  15. Random    =    _LVOFastRandom    ;_LVOFastRandom() or _LVOSlowRandom().
  16.  
  17. CALL    MACRO
  18.     jsr    _LVO\1(a6)
  19.     ENDM
  20.  
  21.     SECTION    "RandomPlot",CODE
  22.  
  23. ;===========================================================================;
  24. ;                             INITIALISE DEMO
  25. ;===========================================================================;
  26.  
  27. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  28.     move.l    ($4).w,a6
  29.     lea    GMS_Name(pc),a1
  30.     moveq    #$00,d0
  31.     CALL    OpenLibrary
  32.     move.l    d0,GMS_Base
  33.     beq.s    .Error_GMS
  34.  
  35.     move.l    GMS_Base(pc),a6
  36.     sub.l    a0,a0
  37.     CALL    SetUserPrefs
  38.  
  39.     CALL    AllocBlitter
  40.     tst.w    d0
  41.     bne.s    .Error_Blitter
  42.  
  43.     lea    Screen(pc),a0
  44.     CALL    AddScreen
  45.     tst.l    d0
  46.     bne.s    .Error_Screen
  47.  
  48.     CALL    ShowScreen
  49.     CALL    InitJoyPorts
  50.     bsr.s    Main
  51.  
  52. .ReturnToDOS
  53.     move.l    GMS_Base(pc),a6
  54.     lea    Screen(pc),a0
  55.     CALL    DeleteScreen
  56. .Error_Screen
  57.     CALL    FreeBlitter
  58. .Error_Blitter
  59.     move.l    GMS_Base(pc),a1
  60.     move.l    ($4).w,a6
  61.     CALL    CloseLibrary
  62. .Error_GMS
  63.     MOVEM.L    (SP)+,A0-A6/D1-D7
  64.     moveq    #$00,d0
  65.     rts
  66.  
  67. ;===========================================================================;
  68. ;                                MAIN LOOP
  69. ;===========================================================================;
  70.  
  71. Main:    move.l    GMS_Base(pc),a6
  72.     lea    Screen(pc),a0
  73. .loop    moveq    #JPORT1,d0
  74.     CALL    ReadMouse
  75.     btst    #MB_LMB,d0
  76.     bne.s    .done
  77.  
  78.     move.l    GS_AmtColours(a0),d1    ;Get random colour.
  79.     subq.l    #1,d1
  80.     jsr    Random(a6)    ;>> = Get random number.
  81.     addq.l    #1,d0
  82.     move.l    d0,d3    ;d3 = Colour to use.
  83.  
  84.     move.w    GS_ScrWidth(a0),d1    ;Get random X.
  85.     jsr    Random(a6)    ;>> = Get random number.
  86.     move.w    d0,d4    ;d4 = Store X to use.
  87.  
  88.     move.w    GS_ScrHeight(a0),d1    ;Get random Y.
  89.     jsr    Random(a6)    ;>> = Get random number.
  90.     move.w    d0,d2    ;d2 = Y to use.
  91.     move.w    d4,d1    ;d1 = Get back X.
  92.  
  93.     moveq    #BUFFER1,d0
  94.     CALL    DrawUCPixel
  95.     bra.s    .loop
  96.  
  97. .done    rts
  98. ;===========================================================================;
  99. ;                                  DATA
  100. ;===========================================================================;
  101.  
  102. GMS_Name:
  103.     dc.b    "games.library",0
  104.     even
  105. GMS_Base:
  106.     dc.l    0
  107.  
  108. Screen:    dc.l    GSV1,0    ;Structure Version.
  109.     dc.l    0,0,0    ;Screen memory 1/2/3
  110.     dc.l    0    ;Screen link.
  111.     dc.l    .Palette    ;Address of palette.
  112.     dc.l    0    ;Address of rasterlist.
  113.     dc.l    32    ;Amount of colours in palette.
  114.     dc.w    640,512    ;Screen Width, Height.
  115.     dc.w    0,0,0    ;Picture Width, ByteWidth, Height.
  116.     dc.w    5    ;Amount of planes
  117.     dc.w    0,0    ;X/Y screen offsets.
  118.     dc.w    0,0    ;X/Y picture offsets.
  119.     dc.l    0    ;Special attributes.
  120.     dc.w    HIRES|COL12BIT|LACED    ;Screen mode.
  121.     dc.w    ILBM    ;Screen type
  122.     even
  123.  
  124. .Palette
  125.     dc.w    $000,$190,$FCB,$FA9,$D88,$965,$644,$211
  126.     dc.w    $406,$444,$FF0,$432,$CC0,$190,$501,$880
  127.     dc.w    $261,$271,$382,$492,$5A3,$5B4,$677,$6C4
  128.     dc.w    $788,$9AA,$BCC,$801,$901,$A02,$701,$601
  129.  
  130.