* the 'Hello World' program in 68000 Assembler * the C version is on page 2-10 of the Intuition manual * this source code (C) HiSoft 1987 All Rights Reserved include intuition/intuition_lib.i include graphics/graphics_lib.i include exec/exec_lib.i * from intuition/intuition.i CLOSEWINDOW EQU $00000200 rsreset Window rs.b 0 wd_NextWindow rs.l 1 wd_LeftEdge rs.w 1 wd_TopEdge rs.w 1 wd_Width rs.w 1 wd_Height rs.w 1 wd_MouseY rs.w 1 wd_MouseX rs.w 1 wd_MinWidth rs.w 1 wd_MinHeight rs.w 1 wd_MaxWidth rs.w 1 wd_MaxHeight rs.w 1 wd_Flags rs.l 1 wd_MenuStrip rs.l 1 wd_Title rs.l 1 wd_FirstRequest rs.l 1 wd_DMRequest rs.l 1 wd_ReqCount rs.w 1 wd_WScreen rs.l 1 wd_RPort rs.l 1 wd_BorderLeft rs.b 1 wd_BorderTop rs.b 1 wd_BorderRight rs.b 1 wd_BorderBottom rs.b 1 wd_BorderRPort rs.l 1 wd_FirstGadget rs.l 1 wd_Parent rs.l 1 wd_Descendant rs.l 1 wd_Pointer rs.l 1 wd_PtrHeight rs.b 1 wd_PtrWidth rs.b 1 wd_XOffset rs.b 1 wd_YOffset rs.b 1 wd_IDCMPFlags rs.l 1 wd_UserPort rs.l 1 wd_WindowPort rs.l 1 wd_MessageKey rs.l 1 wd_DetailPen rs.b 1 wd_BlockPen rs.b 1 wd_CheckMark rs.l 1 wd_ScreenTitle rs.l 1 wd_GZZMouseX rs.w 1 wd_GZZMouseY rs.w 1 wd_GZZWidth rs.w 1 wd_GZZHeight rs.w 1 wd_ExtData rs.l 1 wd_UserData rs.l 1 wd_WLayer rs.l 1 IFont rs.l 1 wd_Size rs.w 0 WINDOWSIZING EQU $0001 WINDOWDRAG EQU $0002 WINDOWDEPTH EQU $0004 WINDOWCLOSE EQU $0008 SMART_REFRESH EQU $0000 ACTIVATE EQU $1000 rsreset NewWindow rs.b 0 nw_LeftEdge rs.w 1 nw_TopEdge rs.w 1 nw_Width rs.w 1 nw_Height rs.w 1 nw_DetailPen rs.b 1 nw_BlockPen rs.b 1 nw_IDCMPFlags rs.l 1 nw_Flags rs.l 1 nw_FirstGadget rs.l 1 nw_CheckMark rs.l 1 nw_Title rs.l 1 nw_Screen rs.l 1 nw_BitMap rs.l 1 nw_MinWidth rs.w 1 nw_MinHeight rs.w 1 nw_MaxWidth rs.w 1 nw_MaxHeight rs.w 1 nw_Type rs.w 1 nw_SIZE rs.w 0 CUSTOMSCREEN EQU $000F TOPAZ_SIXTY EQU 9 * from graphics/text.i FS_NORMAL EQU 0 FPF_ROMFONT equ 1<<0 * from exec/nodes.i rsreset LN rs.b 0 LN_SUCC rs.l 1 LN_PRED rs.l 1 LN_TYPE rs.b 1 LN_PRI rs.b 1 LN_NAME rs.l 1 LN_SIZE rs.w 0 * from exec/lists.i rsreset LH rs.b 0 LH_HEAD rs.l 1 LH_TAIL rs.l 1 LH_TAILPRED rs.l 1 LH_TYPE rs.b 1 LH_pad rs.b 1 LH_SIZE rs.w 0 * from exec/ports.i rsreset MP rs.b LN_SIZE MP_FLAGS rs.b 1 MP_SIGBIT rs.b 1 MP_SIGTASK rs.l 1 MP_MSGLIST rs.b LH_SIZE MP_SIZE rs.w 0 MP_SOFTINT EQU MP_SIGTASK PF_ACTION EQU 3 PA_SIGNAL EQU 0 PA_SOFTINT EQU 1 PA_IGNORE EQU 2 INTUITION_REV equ 31 v1.1 GRAPHICS_REV equ 31 v1.1 * Open the intuition library moveq #100,d4 default error return code moveq #INTUITION_REV,d0 version lea int_name(pc),a1 CALLEXEC OpenLibrary tst.l d0 beq exit_false if failed then quit move.l d0,_IntuitionBase else save the pointer moveq #GRAPHICS_REV,d0 lea graf_name(pc),a1 CALLEXEC OpenLibrary tst.l d0 beq exit_closeint if failed then close Int, exit move.l d0,_GfxBase lea MyNewScreen(pc),a0 CALLINT OpenScreen open a screen tst.l d0 beq exit_closeall if failed the close both, exit move.l d0,MyScreen * now initialise a NewWindow structure. This is normally easier to * do with dc.w/dc.l statement etc, but for comparison with the C * version we do it like this lea MyNewWindow(pc),a0 good place to start move.w #20,nw_LeftEdge(a0) move.w #20,nw_TopEdge(a0) move.w #300,nw_Width(a0) move.w #100,nw_Height(a0) move.b #0,nw_DetailPen(a0) move.b #1,nw_BlockPen(a0) move.l #window_title,nw_Title(a0) _temp set WINDOWCLOSE!SMART_REFRESH!ACTIVATE!WINDOWSIZING move.l #_temp!WINDOWDRAG!WINDOWDEPTH,nw_Flags(a0) move.l #CLOSEWINDOW,nw_IDCMPFlags(a0) move.w #CUSTOMSCREEN,nw_Type(a0) clr.l nw_FirstGadget(a0) clr.l nw_CheckMark(a0) move.l MyScreen(pc),nw_Screen(a0) clr.l nw_BitMap(a0) move.w #100,nw_MinWidth(a0) move.w #25,nw_MinHeight(a0) move.w #640,nw_MaxWidth(a0) move.w #200,nw_MaxHeight(a0) * thats it set up, now open the window (a0=NewWindow already) CALLINT OpenWindow tst.l d0 beq exit_closescr if failed move.l d0,MyWindow save it move.l d0,a1 window move.l wd_RPort(a1),a1 rastport moveq #20,d0 X moveq #20,d1 Y CALLGRAF Move move the cursor move.l MyWindow(pc),a0 move.l wd_RPort(a0),a1 rastport lea hello_message(pc),a0 moveq #11,d0 CALLGRAF Text print something move.l MyWindow(pc),a0 move.l wd_UserPort(a0),a0 move.b MP_SIGBIT(a0),d1 (misprint in manual) moveq #0,d0 bset d1,d0 do a shift CALLEXEC Wait moveq #0,d4 return code * various exit routines that do tidying up, given a return code in d4 move.l MyWindow(pc),a0 CALLINT CloseWindow exit_closescr move.l MyScreen(pc),a0 CALLINT CloseScreen exit_closeall move.l _GfxBase(pc),a1 CALLEXEC CloseLibrary exit_closeint move.l _IntuitionBase(pc),a1 CALLEXEC CloseLibrary exit_false move.l d4,d0 return code rts * the definition of the screen - note that in assembler you * MUST get the sizes of these fields correct, by consulting either * the RKM or the header files MyNewScreen dc.w 0,0 left, top dc.w 320,200 width, height dc.w 2 depth dc.b 0,1 pens dc.w 0 viewmodes dc.w CUSTOMSCREEN type dc.l MyFont font dc.l screen_title title dc.l 0 gadgets dc.l 0 bitmap * my font definition MyFont dc.l font_name dc.w TOPAZ_SIXTY dc.b FS_NORMAL dc.b FPF_ROMFONT * the variables _IntuitionBase dc.l 0 Intuition lib pointer _GfxBase dc.l 0 graphics lib pointer MyScreen dc.l 0 MyWindow dc.l 0 MyNewWindow ds.b nw_SIZE a buffer * some strings int_name INTNAME graf_name GRAFNAME hello_message dc.b 'Hello World' * these are C strings, so have to be null terminated screen_title dc.b 'My Own Screen',0 font_name dc.b 'topaz.font',0 window_title dc.b 'A Simple Window',0