home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / ATX-DP31.DMS / in.adf / Devpac / Examples / helloworld.s < prev    next >
Encoding:
Text File  |  1994-12-16  |  3.8 KB  |  169 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, 1993, 1994 All Rights Reserved
  6.  
  7. * Defines to remove obsolete names from the include files
  8. ASL_V38_NAMES_ONLY    EQU    1
  9. INTUI_V36_NAMES_ONLY    EQU    1
  10. IFFPARSE_V37_NAMES_ONLY    EQU    1
  11.  
  12.     INCLUDE    /system.gs
  13.  
  14.     INCLUDE    intuition/intuition.i
  15.     INCLUDE    graphics/gfxbase.i
  16.     INCLUDE    graphics/text.i
  17.  
  18.     OPT    O+,OW2-
  19.  
  20. TRUE        equ    -1
  21. INTUITION_REV    equ    31        v1.1
  22. GRAPHICS_REV    equ    31        v1.1
  23.  
  24.     SECTION    CODE,CODE
  25. * Open the intuition library
  26.  
  27.     moveq    #100,d4        default error return code
  28.  
  29.     moveq    #INTUITION_REV,d0    version
  30.     lea    int_name(pc),a1
  31.     CALLEXEC    OpenLibrary
  32.     tst.l    d0
  33.     beq    exit_false        if failed then quit
  34.     move.l    d0,_IntuitionBase    else save the pointer
  35.  
  36.     moveq    #GRAPHICS_REV,d0
  37.     lea    graf_name(pc),a1
  38.     CALLEXEC    OpenLibrary
  39.     tst.l    d0
  40.     beq    exit_closeint    if failed then close Int, exit
  41.     move.l    d0,_GfxBase
  42.  
  43.     lea    MyNewScreen,a0
  44.     CALLINT    OpenScreen        open a screen
  45.     tst.l    d0
  46.     beq    exit_closeall    if failed the close both, exit
  47.     move.l    d0,MyScreen
  48.  
  49. * now initialise a NewWindow structure. This is normally easier to
  50. * do with dc.w/dc.l statement etc, but for comparison with the C
  51. * version we do it like this
  52.     lea    MyNewWindow,a0    good place to start
  53.     move.w    #20,nw_LeftEdge(a0)
  54.     move.w    #20,nw_TopEdge(a0)
  55.     move.w    #300,nw_Width(a0)
  56.     move.w    #100,nw_Height(a0)
  57.     move.b    #0,nw_DetailPen(a0)
  58.     move.b    #1,nw_BlockPen(a0)
  59.     move.l    #window_title,nw_Title(a0)
  60. _temp    set    WFLG_CLOSEGADGET!WFLG_NOCAREREFRESH!WFLG_SMART_REFRESH!WFLG_ACTIVATE!WFLG_SIZEGADGET
  61.     move.l    #_temp!WFLG_DRAGBAR!WFLG_DEPTHGADGET,nw_Flags(a0)
  62.     move.l    #IDCMP_CLOSEWINDOW,nw_IDCMPFlags(a0)
  63.     move.w    #CUSTOMSCREEN,nw_Type(a0)
  64.     clr.l    nw_FirstGadget(a0)
  65.     clr.l    nw_CheckMark(a0)
  66.     move.l    MyScreen,nw_Screen(a0)
  67.     clr.l    nw_BitMap(a0)
  68.     move.w    #100,nw_MinWidth(a0)
  69.     move.w    #25,nw_MinHeight(a0)
  70.     move.w    #640,nw_MaxWidth(a0)
  71.     move.w    #200,nw_MaxHeight(a0)
  72.  
  73. * thats it set up, now open the window (a0=NewWindow already)
  74.     CALLINT    OpenWindow
  75.     tst.l    d0
  76.     beq.s    exit_closescr    if failed
  77.     move.l    d0,MyWindow        save it
  78.  
  79.     move.l    d0,a1        window
  80.     move.l    wd_RPort(a1),a1    rastport
  81.     moveq    #20,d0        X
  82.     moveq    #20,d1        Y
  83.     CALLGRAF    Move        move the cursor
  84.  
  85.     move.l    MyWindow,a0
  86.     move.l    wd_RPort(a0),a1    rastport
  87.     lea    hello_message(pc),a0
  88.     moveq    #11,d0
  89.     CALLGRAF    Text        print something
  90.  
  91.     move.l    MyWindow,a0
  92.     move.l    wd_UserPort(a0),a0
  93.     move.b    MP_SIGBIT(a0),d1    (misprint in manual)
  94.     moveq    #0,d0
  95.     bset    d1,d0        do a shift
  96.     CALLEXEC    Wait
  97.  
  98.     moveq    #0,d4        return code
  99.  
  100. * various exit routines that do tidying up, given a return code in d4
  101.  
  102.     move.l    MyWindow,a0
  103.     CALLINT    CloseWindow
  104.  
  105. exit_closescr
  106.     move.l    MyScreen,a0
  107.     CALLINT    CloseScreen
  108.  
  109. exit_closeall
  110.     move.l    _GfxBase,a1
  111.     CALLEXEC    CloseLibrary
  112.  
  113. exit_closeint
  114.     move.l    _IntuitionBase,a1
  115.     CALLEXEC    CloseLibrary
  116.  
  117. exit_false
  118.     move.l    d4,d0                return code
  119.     rts
  120.  
  121. * some strings
  122. int_name    INTNAME
  123. graf_name    GRAPHICSNAME
  124. hello_message    dc.b    'Hello World'
  125.  
  126. * these are C strings, so have to be null terminated
  127. screen_title    dc.b    'My Own Screen',0
  128. font_name    dc.b    'topaz.font',0
  129. window_title    dc.b    'A Simple Window',0
  130.  
  131.     SECTION    DATA,DATA
  132. * the definition of the screen - note that in assembler you
  133. * MUST get the sizes of these fields correct, by consulting either
  134. * the RKM or the header files
  135.  
  136. MyNewScreen:
  137.     dc.w    0,0            left, top
  138.     dc.w    320,200            width, height
  139.     dc.w    2            depth
  140.     dc.b    0,1            pens
  141.     dc.w    0            viewmodes
  142.     dc.w    CUSTOMSCREEN!NS_EXTENDED    type
  143.     dc.l    MyFont            font
  144.     dc.l    screen_title        title
  145.     dc.l    0            gadgets
  146.     dc.l    0            bitmap
  147.     dc.l    MyNewScreenTagList        ens_Extension
  148.  
  149.     EVEN
  150. MyNewScreenTagList
  151.     dc.l    SA_Pens,MyPens
  152.     dc.l    TAG_DONE,0
  153.  
  154. MyPens    dc.w    ~0        minimal pen specification
  155.  
  156. * my font definition
  157. MyFont    dc.l    font_name
  158.     dc.w    TOPAZ_SIXTY
  159.     dc.b    FS_NORMAL
  160.     dc.b    FPF_ROMFONT
  161.  
  162. * the variables
  163. _IntuitionBase    dc.l    0    Intuition lib pointer
  164. _GfxBase    dc.l    0        graphics lib pointer
  165. MyScreen    dc.l    0
  166. MyWindow    dc.l    0
  167. MyNewWindow    ds.b    nw_SIZE        a buffer
  168.  
  169.