home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / ORPSW11.LHA / asm / orpsw.s < prev    next >
Encoding:
Text File  |  1992-09-02  |  34.4 KB  |  1,004 lines

  1. *****************************************************************************
  2. *         SECURITY CONTROL                                                  *
  3. * Compiler: Devpac 3.04                                              ORHAN  *
  4. *****************************************************************************
  5.           MACHINE      MC68000
  6.           INCLUDE      "exec/types.i"
  7.           INCLUDE      "exec/memory.i"
  8.           INCLUDE      "exec/execbase.i"
  9.           INCLUDE      "exec/io.i"
  10.           INCLUDE      "exec/resident.i"
  11.           INCLUDE      "exec/tasks.i"
  12.           INCLUDE      "graphics/gfxbase.i"
  13.           INCLUDE      "graphics/rastport.i"
  14.           INCLUDE      "graphics/modeid.i"
  15.           INCLUDE      "graphics/text.i"
  16.           INCLUDE      "graphics/view.i"
  17.           INCLUDE      "hardware/custom.i"
  18.           INCLUDE      "hardware/dmabits.i"
  19.           INCLUDE      "hardware/intbits.i"
  20.           INCLUDE      "dos/dosextens.i"
  21.           INCLUDE      "devices/input.i"
  22.           INCLUDE      "devices/inputevent.i"
  23.           INCLUDE      "devices/trackdisk.i"
  24.           INCLUDE      "lvo/exec_lib.i"
  25.           INCLUDE      "lvo/dos_lib.i"
  26.           INCLUDE      "lvo/graphics_lib.i"
  27.           INCLUDE      "lvo/keymap_lib.i"
  28.           INCLUDE      "lvo/utility_lib.i"
  29. *****************************************************************************
  30. *         check from cli or boot time                                       *
  31. *****************************************************************************
  32.           SECTION      "CODE",CODE_C
  33.           MOVE.L       ($4),A6
  34.           LEA.L        CONNAME,A1
  35.           CALLSYS      FindTask
  36.           TST.L        D0
  37.           BEQ.S        START
  38.  
  39.           LEA.L        SEMANAME,A1
  40.           CALLSYS      FindSemaphore
  41.           MOVE.L       D0,SEMADR
  42.           BEQ          EXIT
  43.  
  44.           MOVE.L       SEMADR,A1
  45.           LEA.L        RETCODE-MYSEMAFOR(A1),A0
  46.           MOVE.L       (A0),D2
  47.  
  48.           MOVE.L       SEMADR,A1
  49.           CALLSYS      RemSemaphore
  50.  
  51.           MOVE.L       D2,D0
  52.           RTS
  53. *****************************************************************************
  54. *         creat task                                                        *
  55. *****************************************************************************
  56. START:
  57.           CMP.W        #36,LIB_VERSION(A6)
  58.           BLO          ADDFS                     ;check KS2.0+
  59.  
  60.           LEA.L        STARTFLAG,A0              ;check first call
  61.           TST.L        (A0)
  62.           BNE          ADDFS
  63.           NOT.L        (A0)
  64. *****************************************************************************
  65. *         stop floppy drives clicks                                         *
  66. *****************************************************************************
  67.           CALLSYS      CreateMsgPort
  68.           MOVE.L       D0,TRACKPORT
  69.           BEQ.S        CREATETASK
  70.           MOVE.L       D0,A0
  71.           MOVE.L       #IOSTD_SIZE,D0
  72.           CALLSYS      CreateIORequest
  73.           MOVE.L       D0,TRACKREQ
  74.           BEQ.S        CREATETASK
  75.  
  76.           MOVE.L       #NUMUNITS-1,D6
  77. AA12:
  78.           LEA.L        TRACKNAME,A0
  79.           MOVE.L       D6,D0        
  80.           MOVE.L       TRACKREQ,A1
  81.           MOVE.L       #0,D1
  82.           CALLSYS      OpenDevice   
  83.           TST.L        D0
  84.           BNE.S        AA13
  85.  
  86.           MOVE.L       TRACKREQ,A1
  87.           MOVE.L       IO_UNIT(A1),A2
  88.           BSET.B       #TDPB_NOCLICK,TDU_PUBFLAGS(A2)
  89.           MOVE.B       #1,TDU_RETRYCNT(A2)
  90. AA13:     DBF          D6,AA12
  91.                                                 ;dont close device
  92.           MOVE.L       TRACKREQ,A0
  93.           CALLSYS      DeleteIORequest
  94.           MOVE.L       TRACKPORT,A0
  95.           CALLSYS      DeleteMsgPort
  96. *****************************************************************************
  97. *         creat task                                                        *
  98. *****************************************************************************
  99. CREATETASK:
  100.           MOVE.L       ThisTask(A6),MYTASK
  101.           MOVE.L       #-1,D0
  102.           CALLSYS      AllocSignal
  103.           MOVE.L       D0,SIGBIT
  104.           BMI          ADDFS
  105.  
  106.           LEA.L        THEMEMLIST,A0
  107.           CALLSYS      AllocEntry
  108.           BCLR.L       #31,D0
  109.           BNE          ADDFS
  110.           MOVE.L       D0,A1                       ;new memlist
  111.           LEA.L        THETASK,A0
  112.           MOVE.L       ML_ME+ME_ADDR(A1),D0
  113.           MOVE.L       ML_ME+ME_LENGTH(A1),D1
  114.           MOVE.L       #0,LN_NAME(A0)
  115.           MOVE.B       #0,LN_PRI(A0)
  116.           MOVE.B       #NT_TASK,LN_TYPE(A0)
  117.           MOVE.L       D0,TC_SPLOWER(A0)
  118.           ADD.L        D1,D0
  119.           MOVE.L       D0,TC_SPUPPER(A0)
  120.           MOVE.L       TC_SPUPPER(A0),TC_SPREG(A0)
  121.           LEA.L        TC_MEMENTRY(A0),A0
  122.           NEWLIST      A0
  123.           ADDHEAD
  124.  
  125.           LEA.L        THETASK,A1
  126.           LEA.L        CREATVIEW,A2
  127.           MOVE.L       #0,A3
  128.           CALLSYS      AddTask
  129.  
  130.           MOVE.L       SIGBIT,D1
  131.           CLR.L        D0
  132.           BSET.L       D1,D0
  133.           CALLSYS      Wait
  134.  
  135.           MOVE.L       SIGBIT,D0
  136.           CALLSYS      FreeSignal
  137. *****************************************************************************
  138. *         add '*' wildcard character to DOS                                 *
  139. *****************************************************************************
  140.           LEA.L        LibList(A6),A0
  141.           LEA.L        DOSNAME,A1
  142.           CALLSYS      FindName                 ;get DosBase 
  143.           TST.L        D0 
  144.           BEQ.S        ADDFS
  145.  
  146.           MOVE.L       D0,A1
  147.           MOVE.L       dl_Root(A1),A0
  148.           OR.L         #RNF_WILDSTAR,rn_Flags(A0)
  149.       OR.B         #LIBF_CHANGED,LIB_FLAGS(A1)
  150. *****************************************************************************
  151. *         add standard file systems                                         *
  152. *****************************************************************************
  153. ADDFS:
  154.           LEA.L        FSNAME,A1
  155.           CALLSYS      FindResident
  156.           TST.L        D0
  157.           BEQ.S        EXIT
  158.           MOVE.L       D0,A1
  159.           CLR.L        D1
  160.           CALLSYS      InitResident
  161. *****************************************************************************
  162. *         exit                                                              *
  163. *****************************************************************************
  164. EXIT:
  165.           MOVE.L       #0,D0
  166.           RTS
  167. *****************************************************************************
  168. *         creat view  (task)                                                *
  169. *****************************************************************************
  170. CREATVIEW:
  171.           MOVE.L       ($4),A6
  172.           MOVE.W       $DFF000+dmaconr.L,D0
  173.           OR.W         #BITSET,D0
  174.           MOVE.W       D0,SAVEDMA
  175.  
  176.           CALLSYS      CreateMsgPort
  177.           MOVE.L       D0,INPUTPORT
  178.           BEQ          CLEANGFX
  179.           MOVE.L       D0,A0
  180.           MOVE.L       #IOSTD_SIZE,D0
  181.           CALLSYS      CreateIORequest
  182.           MOVE.L       D0,INPUTREQ
  183.           BEQ          CLEANGFX
  184.  
  185.           LEA.L        INPUTNAME,A0
  186.           MOVE.L       INPUTREQ,A1
  187.           MOVE.L       #0,D0
  188.           MOVE.L       #0,D1
  189.           CALLSYS      OpenDevice
  190.           TST.L        D0
  191.           BNE          CLEANGFX
  192.           NOT.L        OPENSTATUSI
  193.  
  194.           LEA.L        INPUTHAND,A0
  195.           MOVE.B       #127,LN_PRI(A0)
  196.           LEA.L        EVENTFLAG,A1
  197.           MOVE.L       A1,IS_DATA(A0)
  198.           LEA.L        INPUTHANDLER,A1
  199.           MOVE.L       A1,IS_CODE(A0)
  200.  
  201.           MOVE.L       INPUTREQ,A1
  202.           LEA.L        INPUTHAND,A0
  203.           MOVE.L       A0,IO_DATA(A1)
  204.           MOVE.W       #IND_ADDHANDLER,IO_COMMAND(A1)
  205.           CALLSYS      DoIO                     ;add input handler
  206.  
  207.           LEA.L        KEYMAPNAME,A1
  208.           CLR.L        D0
  209.           CALLSYS      OpenLibrary    
  210.           MOVE.L       D0,KEYMAPBASE
  211.           BEQ          CLEANGFX
  212.  
  213.           LEA.L        UTILNAME,A1
  214.           CLR.L        D0
  215.           CALLSYS      OpenLibrary
  216.           MOVE.L       D0,UTILBASE
  217.           BEQ          CLEANGFX
  218.  
  219.           LEA.L        GFXNAME,A1
  220.           CLR.L        D0
  221.           CALLSYS      OpenLibrary
  222.           MOVE.L       D0,GFXBASE
  223.           BEQ          CLEANGFX
  224. *****************************************************************************
  225. *         display view                                                      *
  226. *****************************************************************************
  227.           MOVE.L       GFXBASE,A6
  228.           MOVE.L       gb_ActiView(A6),D0
  229.           MOVE.L       D0,OLDVIEW                   ;save current View
  230.  
  231.           LEA.L        THEVIEW,A1
  232.           CALLSYS      InitView
  233.           LEA.L        THEVIEW,A0
  234.           OR.W         #V_LACE,v_Modes(A0)
  235.  
  236.           LEA.L        THEVPORT,A0
  237.           CALLSYS      InitVPort
  238.  
  239.           LEA.L        THEVPORT,A1 
  240.           LEA.L        THERASINFO,A0
  241.           MOVE.L       A0,vp_RasInfo(A1)
  242.           MOVE.W       #WIDTH,vp_DWidth(A1)
  243.           MOVE.W       #HEIGHT,vp_DHeight(A1)
  244.           ADD.W        #(256-HEIGHT)/2,vp_DyOffset(A1)     
  245.                                                          
  246. ;;          SUB.W        #90,vp_DxOffset(A1)        ;for VGA       
  247. ;;          OR.W         #HIRES_KEY,vp_Modes(A1)    ;monitor       
  248.           SUB.W        #26,vp_DxOffset(A1)        ;for PAL       
  249.           OR.W         #LORES_KEY,vp_Modes(A1)    ;monitor       
  250.  
  251.           LEA.L        THEVIEW,A0
  252.           LEA.L        THEVPORT,A1
  253.           MOVE.L       A1,v_ViewPort(A0)
  254.  
  255.           LEA.L        THEBITMAP,A0
  256.           MOVE.L       #DEPTH,D0
  257.           MOVE.L       #WIDTH,D1
  258.           MOVE.L       #HEIGHT,D2
  259.           CALLSYS      InitBitMap
  260.  
  261.           LEA.L        THEBITMAP+bm_Planes,A0       ;clear plane pointers
  262.           MOVE.W       #8-1,D2
  263. CLR1:     CLR.L        (A0)+
  264.           DBF          D2,CLR1
  265.  
  266.           LEA.L        THERASINFO,A0                ;set RasInfo
  267.           LEA.L        THEBITMAP,A1
  268.           MOVE.L       A1,ri_BitMap(A0)
  269.           MOVE.W       #0,ri_RxOffset(A0)
  270.           MOVE.W       #0,ri_RyOffset(A0)
  271.           MOVE.L       #0,ri_Next(A0)
  272.  
  273.           LEA.L        THERASTPORT,A1
  274.           CALLSYS      InitRastPort
  275.           LEA.L        THERASTPORT,A1
  276.           LEA.L        THEBITMAP,A0
  277.           MOVE.L       A0,rp_BitMap(A1)
  278.  
  279.           MOVE.L       #(RAW_DATA-COLORMAP)/2,D0    ;number of colors
  280.           CALLSYS      GetColorMap                  ;initialize ColorMap
  281.           LEA.L        THEVPORT+vp_ColorMap,A0
  282.           MOVE.L       D0,(A0)
  283.           BEQ          CLEANGFX
  284.  
  285.           LEA.L        THEVPORT,A0
  286.           LEA.L        COLORMAP,A1
  287.           MOVE.L       #(RAW_DATA-COLORMAP)/2,D0    ;number of colors
  288.           CALLSYS      LoadRGB4                     ;change colors in table
  289.  
  290.           MOVE.W       THEBITMAP+bm_BytesPerRow,D6
  291.           MULU.W       THEBITMAP+bm_Rows,D6         ;calculate Raster size
  292.           LEA.L        RAW_DATA,A0
  293.           LEA.L        THEBITMAP+bm_Planes,A1
  294.           MOVE.W       #DEPTH-1,D5
  295. ALL1:     MOVE.L       A0,(A1)+
  296.           ADD.L        D6,A0
  297.           DBF          D5,ALL1
  298. *****************************************************************************
  299. *         sort and merge copper lists                                       *
  300. *****************************************************************************
  301.           LEA.L        THEVIEW,A0
  302.           LEA.L        THEVPORT,A1
  303.           CALLSYS      MakeVPort       ;construct preliminary Copper list
  304.  
  305.           LEA.L        THEVIEW,A1
  306.           CALLSYS      MrgCop          ;merge lists into a real list
  307. *****************************************************************************
  308. *         set font                                                          *
  309. *****************************************************************************
  310.           LEA.L        TEXTATTR,A0                 ;initialize text attr
  311.           LEA.L        FONTNAME,A1
  312.           MOVE.L       A1,ta_Name(A0)
  313.           MOVE.W       #8,ta_YSize(A0)
  314.           MOVE.B       #FS_NORMAL,ta_Style(A0)
  315.           MOVE.B       #FPF_DESIGNED|FPF_ROMFONT,ta_Flags(A0)
  316.  
  317.           LEA.L        TEXTATTR,A0
  318.           CALLSYS      OpenFont
  319.           LEA.L        FONTTEXT,A0
  320.           MOVE.L       D0,(A0)
  321.           BEQ          CLEANGFX
  322.  
  323.           LEA.L        THERASTPORT,A1
  324.           MOVE.L       FONTTEXT,A0
  325.           CALLSYS      SetFont
  326.  
  327.           LEA.L        THERASTPORT,A1
  328.           MOVE.L       #RP_JAM2,D0
  329.           CALLSYS      SetDrMd
  330.  
  331.           LEA.L        THEVIEW,A1
  332.           CALLSYS      LoadView               ;display View
  333.           CALLSYS      WaitTOF
  334.           MOVE.W       #BITCLR|DMAF_SPRITE,($DFF000+dmacon)
  335.           MOVE.W       #BITSET|DMAF_MASTER|DMAF_RASTER|DMAF_COPPER,($DFF000+dmacon)
  336. *****************************************************************************
  337. *         check input string                                                *
  338. *****************************************************************************
  339. AA10:
  340.           MOVE.L       #100,D0
  341.           MOVE.L       #040,D1
  342.           MOVE.L       #8,D2
  343.           LEA.L        USERID,A0
  344.           MOVE.L       #'    ',0(A0)
  345.           MOVE.L       #'    ',4(A0)
  346.           BSR          GETSTRING
  347.  
  348.           MOVE.L       #1,RETCODE
  349.           LEA.L        USERID,A0
  350.           LEA.L        TEXT1,A1
  351.           MOVE.L       #8,D0
  352.           LINKSYS      Strnicmp,UTILBASE
  353.           TST.L        D0
  354.           BEQ.S        AA11
  355.  
  356.           LEA.L        USERID,A0
  357.           LEA.L        TEXT0,A1
  358.           MOVE.L       #8,D0
  359.           LINKSYS      Strnicmp,UTILBASE
  360.           TST.L        D0
  361.           BEQ          RESET1
  362.  
  363.           MOVE.L       #5,RETCODE
  364.           LEA.L        USERID,A0
  365.           LEA.L        TEXT2,A1
  366.           MOVE.L       #8,D0
  367.           LINKSYS      Strnicmp,UTILBASE
  368.           TST.L        D0
  369.           BNE          AA10
  370. AA11:
  371. *****************************************************************************
  372. *         write something to semaphore                                      *
  373. *****************************************************************************
  374.           MOVE.L       ($4),A6
  375.           MOVE.L       #LENSEMA,D0
  376.           MOVE.L       #MEMF_PUBLIC,D1
  377.           CALLSYS      AllocMem
  378.           MOVE.L       D0,SEMADR
  379.           BEQ          ERROR
  380.  
  381.           LEA.L        MYSEMAFOR,A0
  382.           MOVE.L       SEMADR,A1
  383.           MOVE.W       #LENSEMA-1,D0
  384. AA3:      MOVE.B       (A0)+,(A1)+
  385.           DBF          D0,AA3
  386.  
  387.           MOVE.L       SEMADR,A0
  388.           CALLSYS      InitSemaphore
  389.  
  390.           MOVE.L       SEMADR,A1
  391.           LEA.L        SEMANAME-MYSEMAFOR(A1),A0
  392.           MOVE.L       A0,LN_NAME(A1)
  393.           MOVE.B       #0,LN_PRI(A1)
  394.  
  395.           MOVE.L       SEMADR,A1
  396.           CALLSYS      AddSemaphore
  397.           BRA.S        CLEANGFX
  398. *****************************************************************************
  399. *         wait vertical blank                                               *
  400. *****************************************************************************
  401. WAITB:
  402.           MOVE.L       $DFF000+vposr.L,D0
  403.           LSR.L        #8,D0
  404.           AND.W        #$07FF,D0
  405.           CMP.W        #290,D0
  406.           BLO          WAITB
  407.           RTS
  408. *****************************************************************************
  409. *         clean up                                                          *
  410. *****************************************************************************
  411. CLEANGFX:
  412.           MOVE.W       #BITCLR|DMAF_RASTER|DMAF_COPPER,($DFF000+dmacon)
  413.           MOVE.W       SAVEDMA,($DFF000+dmacon)
  414.  
  415.           MOVE.L       GFXBASE,A6
  416.           MOVE.L       OLDVIEW,D0
  417.           BEQ.S        CLEAN1
  418.           MOVE.L       D0,gb_ActiView(A6)
  419.           MOVE.L       D0,A1
  420.           CALLSYS      LoadView               ;put back the old View
  421.           CALLSYS      WaitTOF
  422. CLEAN1:
  423.           MOVE.L       THEVPORT+vp_ColorMap,D0
  424.           BEQ.S        CLEAN2
  425.           MOVE.L       D0,A0
  426.           CALLSYS      FreeColorMap
  427. CLEAN2:
  428.           LEA.L        THEVPORT,A0
  429.           TST.L        vp_DspIns(A0)
  430.           BEQ.S        CLEAN33
  431.           CALLSYS      FreeVPortCopLists
  432. CLEAN33:
  433.           MOVE.L       THEVIEW+v_LOFCprList,D0
  434.           BEQ.S        CLEAN3
  435.           MOVE.L       D0,A0
  436.           CALLSYS      FreeCprList
  437. CLEAN3:
  438.           MOVE.L       THEVIEW+v_SHFCprList,D0
  439.           BEQ.S        CLEAN4
  440.           MOVE.L       D0,A0
  441.           CALLSYS      FreeCprList
  442. CLEAN4:
  443.           MOVE.L       FONTTEXT,D0
  444.           BEQ.S        CLEAN44
  445.           MOVE.L       D0,A1
  446.           CALLSYS      CloseFont
  447. CLEAN44:
  448.           MOVE.L       ($4),A6
  449.           MOVE.L       GFXBASE,D0
  450.           BEQ.S        CLEAN5
  451.           MOVE.L       D0,A1
  452.           CALLSYS      CloseLibrary
  453. CLEAN5:
  454.           MOVE.L       OPENSTATUSI,D0
  455.           BEQ.S        CLEAN6
  456.           MOVE.L       INPUTREQ,A1
  457.           LEA.L        INPUTHAND,A0
  458.           MOVE.L       A0,IO_DATA(A1)
  459.           MOVE.W       #IND_REMHANDLER,IO_COMMAND(A1)
  460.           CALLSYS      DoIO
  461.  
  462.           MOVE.L       INPUTREQ,A1
  463.           CALLSYS      CloseDevice
  464.  
  465.           MOVE.L       INPUTREQ,A0
  466.           CALLSYS      DeleteIORequest
  467.           MOVE.L       INPUTPORT,A0
  468.           CALLSYS      DeleteMsgPort
  469. CLEAN6:
  470.           MOVE.L       KEYMAPBASE,D0
  471.           BEQ.S        CLEAN7
  472.           MOVE.L       D0,A1
  473.           CALLSYS      CloseLibrary
  474. CLEAN7:
  475.           MOVE.L       UTILBASE,D0
  476.           BEQ.S        EXITCLEAN
  477.           MOVE.L       D0,A1
  478.           CALLSYS      CloseLibrary
  479. EXITCLEAN:
  480.           MOVE.L       SIGBIT,D1
  481.           CLR.L        D0
  482.           BSET.L       D1,D0
  483.           MOVE.L       MYTASK,A1
  484.           CALLSYS      Signal
  485.  
  486.           MOVE.L       #0,D0
  487.           RTS
  488. *****************************************************************************
  489. *         getstring function   D0=LocX, D1=LocY, D2=lenstr, A0=str          *
  490. *****************************************************************************
  491. GETSTRING:
  492.           MOVEM.L      D0-D7/A0-A6,-(SP)
  493.           LEA.L        LOCX,A1
  494.           MOVE.L       D0,(A1)
  495.           LEA.L        LOCY,A1
  496.           MOVE.L       D1,(A1)
  497.           LEA.L        LENSTR,A1
  498.           MOVE.L       D2,(A1)
  499.           LEA.L        STRADR,A1
  500.           MOVE.L       A0,(A1)
  501.           LEA.L        CURPOS,A1
  502.           CLR.L        (A1)
  503.           LEA.L        CHRPOS,A1
  504.           CLR.L        (A1)
  505.  
  506.           MOVE.L       STRADR,A0
  507.           LEA.L        STRING,A1
  508.           MOVE.L       LENSTR,D1
  509.           SUB.W        #1,D1
  510. CPY2:     MOVE.B       (A0)+,(A1)+
  511.           DBF          D1,CPY2
  512.           MOVE.B       #' ',(A1)
  513.  
  514. WAITKEY:
  515.           BSR          PUTSTRING
  516.           BSR          READKEY
  517.           CMP.L        #KEY_ENTER,KEYRAW
  518.           BEQ.S        KEYENTER
  519.           CMP.L        #KEY_DELETE,KEYRAW
  520.           BEQ.S        KEYDELETE
  521.           CMP.L        #KEY_BACKSPACE,KEYRAW
  522.           BEQ.S        KEYBACKSPACE
  523.           CMP.L        #KEY_LEFT,KEYRAW
  524.           BEQ          KEYLEFT
  525.           CMP.L        #KEY_RIGHT,KEYRAW
  526.           BEQ          KEYRIGHT
  527.           CMP.B        #32,KEYANSI
  528.           BLS          WAITKEY
  529.           CMP.B        #126,KEYANSI
  530.           BHI          WAITKEY
  531.           BRA          PUTCHAR
  532.  
  533. KEYENTER:
  534.           LEA.L        STRING,A0
  535.           MOVE.L       STRADR,A1
  536.           MOVE.L       LENSTR,D1
  537.           SUB.W        #1,D1
  538. CPY3:     MOVE.B       (A0)+,(A1)+
  539.           DBF          D1,CPY3
  540.           MOVE.B       #' ',(A1)
  541.           BRA          EXITSTRING
  542.  
  543. KEYDELETE:
  544.           MOVE.L       CURPOS,D0
  545.           CMP.L        LENSTR,D0
  546.           BGE.S        AA6
  547.  
  548.           LEA.L        STRING,A0
  549.           ADD.L        CURPOS,A0
  550.           MOVE.L       LENSTR,D0
  551.           SUB.L        CURPOS,D0
  552.           SUB.W        #1,D0
  553. CPY4:     MOVE.B       1(A0),(A0)+
  554.           DBF          D0,CPY4
  555. AA6:      BRA          WAITKEY
  556.  
  557. KEYBACKSPACE:
  558.           LEA.L        CURPOS,A0
  559.           TST.L        (A0)
  560.           BEQ.S        AA5
  561.           SUB.L        #1,(A0)
  562.  
  563.           LEA.L        STRING,A0
  564.           ADD.L        CURPOS,A0
  565.           MOVE.L       LENSTR,D0
  566.           SUB.L        CURPOS,D0
  567.           SUB.W        #1,D0
  568. CPY5:     MOVE.B       1(A0),(A0)+
  569.           DBF          D0,CPY5
  570. AA5:      BRA          WAITKEY
  571.  
  572. KEYLEFT:
  573.           LEA.L        CURPOS,A0
  574.           TST.L        (A0)
  575.           BEQ.S        AA7
  576.           SUB.L        #1,(A0)
  577. AA7:      BRA          WAITKEY
  578.  
  579. KEYRIGHT:
  580.           LEA.L        STRING,A0
  581.           ADD.L        CURPOS,A0
  582.           CMP.B        #' ',(A0)
  583.           BEQ.S        AA8
  584.           LEA.L        CURPOS,A0
  585.           MOVE.L       LENSTR,D0
  586.           CMP.L        (A0),D0
  587.           BLS.S        AA8
  588.           ADD.L        #1,(A0)
  589. AA8:      BRA          WAITKEY
  590.  
  591. PUTCHAR:
  592.           MOVE.L       CURPOS,D0
  593.           CMP.L        LENSTR,D0
  594.           BGE.S        DISPFLASH
  595.  
  596.           LEA.L        STRING,A0
  597.           ADD.L        LENSTR,A0
  598.           CMP.B        #' ',-1(A0)
  599.           BNE.S        DISPFLASH
  600.  
  601.           LEA.L        STRING,A0
  602.           MOVE.L       LENSTR,D0
  603. AA4:      SUB.L        #1,D0
  604.           MOVE.B       (A0,D0.L),1(A0,D0.L)
  605.           CMP.L        CURPOS,D0
  606.           BGT          AA4
  607.  
  608.           LEA.L        STRING,A0
  609.           ADD.L        LENSTR,A0
  610.           MOVE.B       #' ',(A0)
  611.  
  612.           LEA.L        STRING,A0
  613.           ADD.L        CURPOS,A0
  614.           MOVE.B       KEYANSI,(A0)
  615.  
  616.           LEA.L        CURPOS,A0
  617.           ADD.L        #1,(A0)
  618.           BRA          WAITKEY
  619. DISPFLASH:
  620.           MOVE.W       #12,D2
  621. LOOP0:    NEG.W        D2
  622.           BEQ          WAITKEY
  623.           BLT.S        AA9
  624.           SUB.W        #2,D2
  625. AA9:      ADD.W        #1,D2
  626.           MOVE.L       GFXBASE,A6
  627.           LEA.L        THEVPORT,A0
  628.           ADD.W        D2,vp_DxOffset(A0)
  629.           CALLSYS      ScrollVPort
  630.           LEA.L        THEVPORT,A0
  631.           SUB.W        D2,vp_DxOffset(A0)
  632.           BRA          LOOP0
  633. EXITSTRING:
  634.           MOVEM.L      (SP)+,D0-D7/A0-A6
  635.           RTS
  636. *****************************************************************************
  637. *         putstring                                                         *
  638. *****************************************************************************
  639. PUTSTRING:
  640.           MOVEM.L      D0-D7/A0-A6,-(SP)
  641.  
  642.           LEA.L        STRING,A0
  643.           LEA.L        STRING2,A1
  644.           MOVE.L       LENSTR,D0           ;+1 extra byte to display
  645. AA14:     MOVE.B       (A0)+,(A1)+
  646.           CMP.B        #' ',-1(A0)         
  647.           BEQ.S        AA15
  648.           MOVE.B       #'*',-1(A1)
  649. AA15      DBF          D0,AA14 
  650.  
  651.  
  652.           MOVE.L       GFXBASE,A6
  653.           LEA.L        THERASTPORT,A1
  654.           MOVE.L       #14,D0
  655.           CALLSYS      SetAPen
  656.  
  657.           LEA.L        THERASTPORT,A1
  658.           MOVE.L       #15,D0
  659.           CALLSYS      SetBPen
  660.  
  661.           LEA.L        THERASTPORT,A1
  662.           MOVE.L       LOCX,D0
  663.           MOVE.L       LOCY,D1
  664.           CALLSYS      Move                    ;set pen position
  665.  
  666.           LEA.L        THERASTPORT,A1
  667.           LEA.L        STRING2,A0
  668.           MOVE.L       LENSTR,D0
  669.           ADD.L        #1,D0
  670.           CALLSYS      Text                    ;write text
  671.  
  672.           LEA.L        THERASTPORT,A1
  673.           MOVE.L       #13,D0
  674.           CALLSYS      SetAPen
  675.  
  676.           LEA.L        THERASTPORT,A1
  677.           MOVE.L       #12,D0
  678.           CALLSYS      SetBPen
  679.  
  680.           LEA.L        THERASTPORT,A1
  681.           MOVE.L       CURPOS,D0
  682.           LSL.L        #3,D0                   ;mul font X size
  683.           ADD.L        LOCX,D0
  684.           MOVE.L       LOCY,D1
  685.           CALLSYS      Move                    ;set pen position
  686.  
  687.           LEA.L        THERASTPORT,A1
  688.           LEA.L        STRING2,A0
  689.           ADD.L        CURPOS,A0
  690.           MOVE.L       #1,D0
  691.           CALLSYS      Text                    ;write text
  692.  
  693.           MOVEM.L      (SP)+,D0-D7/A0-A6
  694.           RTS
  695. *****************************************************************************
  696. *         read keyboard event                         ret: KEYRAW, KEYANSI  *
  697. *****************************************************************************
  698. READKEY:
  699.           MOVEM.L      D0-D7/A0-A6,-(SP)
  700. WAITE:    LEA.L        EVENTFLAG,A0
  701.           MOVE.L       (A0),D0
  702.           BEQ          WAITE
  703.           CLR.L        (A0)
  704.  
  705.           MOVE.L       D0,A0
  706.           LEA.L        KEYRAW,A1
  707.           MOVE.W       ie_Code(A0),2(A1)
  708.           AND.L        #$FF,(A1)
  709.           CMP.L        #$7F,(A1)
  710.           BHI          WAITE
  711.  
  712.           MOVE.L       KEYMAPBASE,A6
  713.           MOVE.L       D0,A0
  714.           LEA.L        KEYANSI,A1
  715.           MOVE.L       #4,D1
  716.           MOVE.L       #0,A2
  717.           CALLSYS      MapRawKey
  718.           TST.L        D0
  719.           BEQ          WAITE
  720.           BMI          ERROR
  721.  
  722.           MOVEM.L      (SP)+,D0-D7/A0-A6
  723.           RTS
  724. *****************************************************************************
  725. *         input handler                                                     *
  726. *****************************************************************************
  727. INPUTHANDLER:
  728.           CMP.B        #IECLASS_RAWKEY,ie_Class(A0)
  729.           BNE.S        NEXTEVENT
  730.           MOVE.L       A0,(A1)                     ;save input event
  731. NEXTEVENT:
  732.           MOVE.L       ie_NextEvent(A0),D0
  733.           MOVE.L       D0,A0
  734.           BNE          INPUTHANDLER
  735.  
  736.           MOVE.L       #0,D0                       ;return event list or NULL
  737.           RTS
  738. *****************************************************************************
  739. *          software reset                                                   *
  740. *****************************************************************************
  741. RESET1:
  742.           MOVE.L       ($4),A6
  743.           MOVE.L       #LENCOP,D0
  744.           MOVE.L       #MEMF_CHIP,D1
  745.           CALLSYS      AllocMem
  746.           MOVE.L       D0,MYCOP
  747.           BEQ          ERROR
  748.           BSR.S        SETCOP
  749.  
  750.           LEA.L        SUPMOD,A0
  751.           MOVE.L       A0,($80)
  752.           TRAP         #0
  753. SUPMOD:   MOVE.W       #$2700,SR
  754.           CLR.L        $4
  755.           LEA.L        $F80002.L,A0
  756.           BRA.S        RESETVEC
  757.           CNOP         0,4
  758. RESETVEC: RESET
  759.           JMP          (A0)
  760. *****************************************************************************
  761. *         creat copper list                                                 *
  762. *****************************************************************************
  763. SETCOP:
  764.           LEA.L        $DFF000.L,A6
  765.           MOVE.W       #BITCLR|DMAF_RASTER|DMAF_SPRITE,dmacon(A6)
  766.  
  767.           MOVE.L       MYCOP,A0
  768.           MOVE.L       #LINESTART,D1
  769.           MOVE.W       #LINECOUNT,D2
  770.           SUB.W        #1,D2
  771. L004:
  772.           MOVE.L       #$0035FFFE,(A0)
  773.           MOVE.B       D1,(A0)
  774.           ADD.L        #4,A0
  775.           MOVE.L       #$01800000,(A0)+
  776.  
  777.           MOVE.W       #46,D4
  778.           SUB.W        #1,D4
  779. L325:     MOVE.L       #$01BE0000,(A0)+
  780.           DBF          D4,L325
  781.  
  782.           ADD.L        #1,D1
  783.           DBF          D2,L004
  784.  
  785.           MOVE.L       #$01800000,(A0)+
  786.           MOVE.L       #$FFFFFFFE,(A0)
  787.  
  788.           MOVE.L       MYCOP,A0
  789.           MOVE.L       A0,cop1lc(A6)
  790.           MOVE.W       #0,copjmp1(A6)
  791.           MOVE.W       #BITSET|DMAF_MASTER|DMAF_COPPER,dmacon(A6)
  792. *****************************************************************************
  793. *         renklendirme                                                      *
  794. *****************************************************************************
  795.           CLR.L        D0
  796.           MOVE.W       vhposr(A6),D0
  797.           DIVU.W       #COLOREND-COLORS,D0
  798.           CLR.W        D0
  799.           SWAP         D0
  800.           BCLR.L       #0,D0
  801.           LEA.L        COLORPTR,A0
  802.           MOVE.L       D0,(A0)
  803. L16:
  804.           LEA.L        COLORPTR,A1
  805.           ADD.L        #2,(A1)
  806.           CMP.L        #(COLOREND-COLORS),(A1)
  807.           BLT.S        L77
  808.           SUB.L        #(COLOREND-COLORS),(A1)
  809. L77:
  810.           MOVE.L       (A1),D3
  811.           MOVE.L       D3,D1
  812.           LEA.L        COLORS,A1
  813.           MOVE.L       MYCOP,A0
  814.           ADD.L        #6,A0
  815.           MOVE.W       #LINECOUNT-1,D2
  816. L15:
  817.           MOVE.L       D2,D4
  818.           DIVU.W       #11,D4
  819.           SWAP         D4
  820.           TST.W        D4
  821.           BNE.S        L676
  822.           ADD.L        #2,D3
  823.           CMP.L        #(COLOREND-COLORS),D3
  824.           BLT.S        L678
  825.           MOVE.L       #0,D3
  826. L678:     MOVE.L       D3,D1
  827. L676:
  828.           MOVE.W       (A1,D1.L),(A0)
  829.           ADD.L        #48*4,A0
  830.  
  831.           ADD.L        #2,D1
  832.           CMP.L        #(COLOREND-COLORS),D1
  833.           BLT.S        L777
  834.           MOVE.L       #0,D1
  835. L777:     DBF          D2,L15
  836.  
  837.           BSR.S        WBLANK
  838.           TST.L        D0
  839.           BEQ          L16
  840.  
  841.           MOVE.W       #BITCLR|DMAF_COPPER,dmacon(A6)
  842.           NOP
  843.           NOP
  844.           MOVE.W       #0,color(A6)
  845.           RTS
  846. *****************************************************************************
  847. *         wait vertical blank                                               *
  848. *****************************************************************************
  849. WBLANK:
  850.           MOVE.L       vposr(A6),D0
  851.           LSR.L        #8,D0
  852.           AND.W        #$07FF,D0
  853.           CMP.W        #LINESTART+LINECOUNT,D0
  854.           BNE          WBLANK
  855.  
  856.           MOVE.L       COUNTVB,D0
  857.           ADD.L        #1,D0
  858.           DIVU.W       #55,D0
  859.           SWAP         D0
  860.           MOVE.W       D0,COUNTVB+2
  861.           BEQ.S        OKCNT
  862.  
  863.           MOVEQ.L      #0,D0
  864.           RTS
  865. OKCNT:    MOVEQ.L      #-1,D0
  866.           RTS
  867. *****************************************************************************
  868. *         error                                                             *
  869. *****************************************************************************
  870. ERROR:
  871.            LEA.L       SUPMOD1,A0
  872.            MOVE.L      A0,($80)
  873.            TRAP        #0
  874. SUPMOD1:   MOVE.W      #$2700,SR
  875.            MOVE.W      #$7FFF,($DFF000+dmacon)
  876.            CLR.L       $4
  877. WAIT2:     MOVE.W      #$00CC,($DFF000+color)
  878.            MOVE.W      #$0000,($DFF000+color)
  879.            BRA         WAIT2
  880. *****************************************************************************
  881. *         module data                                                       *
  882. *****************************************************************************
  883. THEVIEW     DCB.B      v_SIZEOF              ;STRUCTURE View,v_SIZEOF
  884. THEVPORT    DCB.B      vp_SIZEOF             ;STRUCTURE ViewPort,vp_SIZEOF
  885. THEBITMAP   DCB.B      bm_SIZEOF             ;STRUCTURE BitMap,bm_SIZEOF
  886. THERASINFO  DCB.B      ri_SIZEOF             ;STRUCTURE RasInfo,ri_SIZEOF
  887. THERASTPORT DCB.B      rp_SIZEOF             ;STRUCTURE RastPort,rp_SIZEOF
  888. TEXTATTR    DCB.B      ta_SIZEOF             ;STRUCTURE TextAttr,ta_SIZEOF
  889. INTSTRUCT   DCB.B      IS_SIZE               ;STRUCTURE IS,IS_SIZE
  890. INPUTHAND   DCB.B      IS_SIZE               ;STRUCTURE IS,IS_SIZE
  891. THETASK     DCB.B      TC_SIZE               ;STRUCTURE TC_Struct,TC_SIZE
  892.  
  893. MYSEMAFOR:
  894.             DCB.B      SS_SIZE               ;STRUCTURE SS,SS_SIZE
  895. RETCODE     DC.L       0
  896. SEMANAME    DC.B       'orpsw',0
  897. LENSEMA     EQU        *-MYSEMAFOR
  898.  
  899. THEMEMLIST:                                  ;for task stack
  900.             DCB.B      LN_SIZE               ;STRUCTURE ML,LN_SIZE
  901.             DC.W       1                     ;UWORD ML_NUMENTRIES
  902.             DC.L       MEMF_PUBLIC           ;LABEL ML_ME      (ME_REQS)
  903.             DC.L       2048                  ;                 (ME_LENGTH)
  904.                                              ;LABEL ML_SIZE
  905.  
  906. KEY_ESC     EQU        $45
  907. KEY_ENTER   EQU        $44
  908. KEY_F1      EQU        $50
  909. KEY_F2      EQU        $51
  910. KEY_DELETE  EQU        $46
  911. KEY_UP      EQU        $4C
  912. KEY_DOWN    EQU        $4D
  913. KEY_LEFT    EQU        $4F
  914. KEY_RIGHT   EQU        $4E
  915. KEY_BACKSPACE EQU      $41
  916.  
  917. SIGBIT      DC.L       0
  918. INPUTPORT   DC.L       0
  919. TRACKPORT   DC.L       0
  920. INPUTREQ    DC.L       0
  921. TRACKREQ    DC.L       0
  922. OPENSTATUSI DC.L       0
  923. MYTASK      DC.L       0
  924. SEMADR      DC.L       0
  925. SAVEDMA     DC.W       0
  926. STARTFLAG   DC.L       0
  927. SOUNDFLAG   DC.L       0
  928. EVENTFLAG   DC.L       0
  929. KEYRAW      DC.L       0
  930. KEYANSI     DC.L       0
  931. OLDVIEW     DC.L       0
  932. LOCX        DC.L       0
  933. LOCY        DC.L       0
  934. CURPOS      DC.L       0
  935. CHRPOS      DC.L       0
  936. LENSTR      DC.L       0
  937. STRADR      DC.L       0
  938. FONTTEXT    DC.L       0
  939. GFXBASE     DC.L       0
  940. KEYMAPBASE  DC.L       0
  941. UTILBASE    DC.L       0
  942. CONNAME     DC.B       'CON',0
  943. FSNAME      DC.B       'filesystem',0
  944. GFXNAME     DC.B       'graphics.library',0
  945. DOSNAME     DC.B       'dos.library',0
  946. FONTNAME    DC.B       'topaz.font',0
  947. INPUTNAME   DC.B       'input.device',0
  948. KEYMAPNAME  DC.B       'keymap.library',0
  949. UTILNAME    DC.B       'utility.library',0
  950. TRACKNAME   DC.B       'trackdisk.device',0
  951. STRING      DCB.B      20
  952. STRING2     DCB.B      20
  953. USERID      DCB.B      20
  954. TEXT0       DC.B       'RESET   '
  955. TEXT1       DC.B       'FLAME   '
  956. TEXT2       DC.B       'ZONE    '
  957. VERSION     DC.B       '$VER: Orpsw 1.1 (01.Apr.96) © by OR',13,10,0
  958.             EVEN
  959.  
  960. LINESTART EQU          28
  961. LINECOUNT EQU          280
  962. LENCOP    EQU          55*1024
  963. COUNTVB   DC.L         0
  964. COLORPTR  DC.L         0
  965. MYCOP     DC.L         0
  966. COLORS:
  967.           DC.W         $110,$220,$330,$440,$550,$660,$770
  968.           DC.W         $880,$990,$AA0,$BB0,$CC0,$DD0,$EE0,$FF0
  969.           DC.W         $EE0,$DD0,$CC0,$BB0,$AA0,$990,$880
  970.           DC.W         $770,$660,$550,$440,$330,$220,$110
  971.  
  972.           DC.W         $101,$202,$303,$404,$505,$606,$707
  973.           DC.W         $808,$909,$A0A,$B0B,$C0C,$D0D,$E0E,$F0F
  974.           DC.W         $E0E,$D0D,$C0C,$B0B,$A0A,$909,$808
  975.           DC.W         $707,$606,$505,$404,$303,$202,$101
  976.  
  977.           DC.W         $111,$222,$333,$444,$555,$666,$777
  978.           DC.W         $888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
  979.           DC.W         $EEE,$DDD,$CCC,$BBB,$AAA,$999,$888
  980.           DC.W         $777,$666,$555,$444,$333,$222,$111
  981.  
  982.           DC.W         $011,$022,$033,$044,$055,$066,$077
  983.           DC.W         $088,$099,$0AA,$0BB,$0CC,$0DD,$0EE,$0FF
  984.           DC.W         $0EE,$0DD,$0CC,$0BB,$0AA,$099,$088
  985.           DC.W         $077,$066,$055,$044,$033,$022,$011
  986.  
  987.           DC.W         $001,$002,$003,$004,$005,$006,$007
  988.           DC.W         $008,$009,$00A,$00B,$00C,$00D,$00E,$00F
  989.           DC.W         $00E,$00D,$00C,$00B,$00A,$009,$008
  990.           DC.W         $007,$006,$005,$004,$003,$002,$001
  991.  
  992.           DC.W         $010,$020,$030,$040,$050,$060,$070
  993.           DC.W         $080,$090,$0A0,$0B0,$0C0,$0D0,$0E0,$0F0
  994.           DC.W         $0E0,$0D0,$0C0,$0B0,$0A0,$090,$080
  995.           DC.W         $070,$060,$050,$040,$030,$020,$010
  996.  
  997.           DC.W         $100,$200,$300,$400,$500,$600,$700
  998.           DC.W         $800,$900,$A00,$B00,$C00,$D00,$E00,$F00
  999.           DC.W         $E00,$D00,$C00,$B00,$A00,$900,$800
  1000.           DC.W         $700,$600,$500,$400,$300,$200,$100
  1001. COLOREND:
  1002.           INCLUDE     "aa.raw.asm"
  1003.           END
  1004.