home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / DVP30_1.DMS / in.adf / Devpac / Examples / helloworld.s < prev    next >
Encoding:
Text File  |  1992-02-27  |  3.7 KB  |  158 lines

  1.  
  2. * the 'Hello World' program in 68000 Assembler
  3. * the C version can be found in the Intuition manual
  4.  
  5. * this source code (C) HiSoft 1992 All Rights Reserved
  6.  
  7. * for Devpac Amiga Version 2 the following symbols were changed
  8. * to avoid clashes with the new include files:
  9. * Screen->MyScreen, NewScreen->MyNewScreen
  10. * Window->MyWindow, NewWindow->MyNewWindow
  11.  
  12.     opt    c+,d+
  13.  
  14.     include    /system            use pre-assembled header
  15.     include    exec/exec_lib.i
  16.     include    intuition/intuition.i
  17.     include    intuition/intuition_lib.i
  18.     include    graphics/graphics_lib.i
  19.     include    graphics/text.i
  20.  
  21. INTUITION_REV    equ    31        v1.1
  22. GRAPHICS_REV    equ    31        v1.1
  23.  
  24. * Open the intuition library
  25.  
  26.     moveq    #100,d4            default error return code
  27.  
  28.     moveq    #INTUITION_REV,d0    version
  29.     lea    int_name(pc),a1
  30.     CALLEXEC OpenLibrary
  31.     tst.l    d0
  32.     beq    exit_false        if failed then quit
  33.     move.l    d0,_IntuitionBase    else save the pointer
  34.  
  35.     moveq    #GRAPHICS_REV,d0
  36.     lea    graf_name(pc),a1
  37.     CALLEXEC OpenLibrary
  38.     tst.l    d0
  39.     beq    exit_closeint        if failed then close Int, exit
  40.     move.l    d0,_GfxBase
  41.  
  42.     lea    MyNewScreen(pc),a0
  43.     CALLINT    OpenScreen        open a screen
  44.     tst.l    d0
  45.     beq    exit_closeall        if failed the close both, exit
  46.     move.l    d0,MyScreen
  47.  
  48. * now initialise a NewWindow structure. This is normally easier to
  49. * do with dc.w/dc.l statement etc, but for comparison with the C
  50. * version we do it like this
  51.     lea    MyNewWindow(pc),a0    good place to start
  52.     move.w    #20,nw_LeftEdge(a0)
  53.     move.w    #20,nw_TopEdge(a0)
  54.     move.w    #300,nw_Width(a0)
  55.     move.w    #100,nw_Height(a0)
  56.     move.b    #0,nw_DetailPen(a0)
  57.     move.b    #1,nw_BlockPen(a0)
  58.     move.l    #window_title,nw_Title(a0)
  59. _temp    set    WINDOWCLOSE!SMART_REFRESH!ACTIVATE!WINDOWSIZING
  60.     move.l    #_temp!WINDOWDRAG!WINDOWDEPTH,nw_Flags(a0)
  61.     move.l    #CLOSEWINDOW,nw_IDCMPFlags(a0)
  62.     move.w    #CUSTOMSCREEN,nw_Type(a0)
  63.     clr.l    nw_FirstGadget(a0)
  64.     clr.l    nw_CheckMark(a0)
  65.     move.l    MyScreen(pc),nw_Screen(a0)
  66.     clr.l    nw_BitMap(a0)
  67.     move.w    #100,nw_MinWidth(a0)
  68.     move.w    #25,nw_MinHeight(a0)
  69.     move.w    #640,nw_MaxWidth(a0)
  70.     move.w    #200,nw_MaxHeight(a0)
  71.  
  72. * thats it set up, now open the window (a0=NewWindow already)
  73.     CALLINT    OpenWindow
  74.     tst.l    d0
  75.     beq    exit_closescr            if failed
  76.     move.l    d0,MyWindow            save it
  77.  
  78.     move.l    d0,a1                window
  79.     move.l    wd_RPort(a1),a1            rastport
  80.     moveq    #20,d0                X
  81.     moveq    #20,d1                Y
  82.     CALLGRAF Move                move the cursor
  83.  
  84.     move.l    MyWindow(pc),a0
  85.     move.l    wd_RPort(a0),a1            rastport
  86.     lea    hello_message(pc),a0
  87.     moveq    #11,d0
  88.     CALLGRAF Text                print something
  89.  
  90.     move.l    MyWindow(pc),a0
  91.     move.l    wd_UserPort(a0),a0
  92.     move.b    MP_SIGBIT(a0),d1        (misprint in manual)
  93.     moveq    #0,d0
  94.     bset    d1,d0                do a shift
  95.     CALLEXEC Wait
  96.  
  97.     moveq    #0,d4                return code
  98.  
  99. * various exit routines that do tidying up, given a return code in d4
  100.  
  101.     move.l    MyWindow(pc),a0
  102.     CALLINT CloseWindow
  103.  
  104. exit_closescr
  105.     move.l    MyScreen(pc),a0
  106.     CALLINT CloseScreen
  107.  
  108. exit_closeall
  109.     move.l    _GfxBase(pc),a1
  110.     CALLEXEC CloseLibrary
  111.  
  112. exit_closeint
  113.     move.l    _IntuitionBase(pc),a1
  114.     CALLEXEC CloseLibrary
  115.  
  116. exit_false
  117.     move.l    d4,d0                return code
  118.     rts
  119.  
  120. * the definition of the screen - note that in assembler you
  121. * MUST get the sizes of these fields correct, by consulting either
  122. * the RKM or the header files
  123.  
  124. MyNewScreen    dc.w    0,0        left, top
  125.         dc.w    320,200        width, height
  126.         dc.w    2        depth
  127.         dc.b    0,1        pens
  128.         dc.w    0        viewmodes
  129.         dc.w    CUSTOMSCREEN    type
  130.         dc.l    MyFont        font
  131.         dc.l    screen_title    title
  132.         dc.l    0        gadgets
  133.         dc.l    0        bitmap
  134.  
  135. * my font definition
  136. MyFont    dc.l    font_name
  137.     dc.w    TOPAZ_SIXTY
  138.     dc.b    FS_NORMAL
  139.     dc.b    FPF_ROMFONT
  140.  
  141. * the variables
  142. _IntuitionBase    dc.l    0        Intuition lib pointer
  143. _GfxBase    dc.l    0        graphics lib pointer
  144. MyScreen        dc.l    0
  145. MyWindow        dc.l    0
  146. MyNewWindow    ds.b    nw_SIZE        a buffer
  147.  
  148.  
  149. * some strings
  150. int_name    INTNAME
  151. graf_name    GRAFNAME
  152. hello_message    dc.b    'Hello World'
  153.  
  154. * these are C strings, so have to be null terminated
  155. screen_title    dc.b    'My Own Screen',0
  156. font_name    dc.b    'topaz.font',0
  157. window_title    dc.b    'A Simple Window',0
  158.