; Printer Controller (PC). Written By  Kamran Karimi
;Sends ESCAPE codes to printer according to ANSI X3.64 Standard
; Compiled With Profimat Assembler From 'DATA BECKER' 
;On an Amiga 500 with OS1.3 


ROM_ROUTINE_ADDRESSES:
ExecBase       equ  4
Open           equ -30
Close          equ -36
Read           equ -42
Write          equ -48
OpenLib        equ -408
CloseLib       equ -414
GetMsg         equ -372
OpenWindow     equ -204
CloseWindow    equ -72
AutoRequest    equ -348
SetMenuStrip   equ -264
ClearMenuStrip equ -54
DisplayBeep    equ -96
PrintIText     equ -216
DrawBorder     equ -108
WaitPort       equ -384
FindTask       equ -294
ReplyMsg       equ -378

CLI_WB:             ;from WB or CLI?
 move.l ExecBase,a6
 move.l #0,a1
 jsr    FindTask(a6)
 move.l d0,a2
 tst.l  $ac(a2)
 bne    OPENING_NECESSARY_STUFF   ;from CLI!
 lea    $5c(a2),a0
 jsr    WaitPort(a6)
 lea    $5c(a2),a0
 jsr    GetMsg(a6)   ;get the WB message but we don't need it

OPENING_NECESSARY_STUFF:
Open_Intuition:
 move.l #20,DOSResult
 move.l ExecBase,a6
 lea    Intuition_Name,a1
 moveq  #0,d0              ;any version
 jsr    OpenLib(a6)
 move.l d0,Intuition_Base   ;we (hopefully) opened intuition.library
 beq    Close_Intuition
Open_DOS:
 lea    DOS_Name,a1
 moveq  #0,d0
 jsr    OpenLib(a6)
 move.l d0,DOS_Base
 beq    Close_DOS      ;we (hopefully) opened the dos.library
 bra    FirstStart   ;we open the small window at the begining

Window_Opening:
 move.l Intuition_Base,a6
 lea    Window_Parameters,a0    ;window specifications
 jsr    OpenWindow(a6)
 move.l d0,Window_Handler
 beq    Close_DOS
 lea    Border1,a1  ;the border arount message box and start,end columns
 move.l #190,d0     ;absolute X pos.
 move.l #65,d1      ;absolute Y pos.
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 move.l 50(a0),a0        ;window rastport
 jsr    DrawBorder(a6)
Set_Menu:
 jsr    SetM
 lea    Intro,a1   ;write 'By Kamran Karimi'
 jsr    Prompting
 lea    Stext,a1   ;write 'Start Column'
 move.l #145,d0    ;X pos.
 move.l #45,d1     ;Y pos.
 jsr    SI         ;write
 lea    Etext,a1   ;write 'End Column'
 move.l #280,d0
 move.l #45,d1
 jsr    SI
 lea    UnKnown,a1  ;write '???'
 move.l #180,d0
 move.l #56,d1
 jsr    SI
 lea    UnKnown,a1
 move.l #305,d0
 move.l #56,d1
 jsr    SI
 jsr    Find_Event     ;find intuition event
 lea    Menu_Bars,a1
 jsr    Prompting     ;change prompt in message box
 bra    START

loop:
 jsr    SetM
FEvent:
 jsr    Reply
 jsr    Find_Event
START:
 jsr    UpDate         ;update start and end columns
 move.l Event,a0
 move.l $14(a0),d6
 cmp    #$200,d6        ;window_close selected?
 beq    End_Requested
 cmp    #$100,d6        ;menu chosen?
 beq    Chosen
 bra    FEvent           ;no important event .loop on
chosen:
 move   $18(a0),d7
 jsr    CLRMenu     ;wipe menu structure because we may have to change it!
 cmp    #$FFFF,d7    ;only right button pressed?
 beq    loop
Real_Selection:
 move   d7,d6
 andi   #$1f,d6      ;d6 has the menu column number
 cmp    #$0,d6
 beq    Style_Column
 cmp    #$1,d6
 beq    Character_Column
 cmp    #$2,d6
 beq    Control_Column
 cmp    #$3,d6
 beq    Print_Column
 bra    StandBy_COLUMN   ;if it was not the other columns it must be this!

Style_Column:
 move   d7,d6
 lsr    #5,d6      ;we want the menu item number
 andi   #$3f,d6       ;and only that!
 move   d6,d5
 move   #0,charset 
 lea    menu11,a1
 mulu   #34,d6
 add    #32,d6  ;obtain the next selected menu at the end of menu structure
 adda.l d6,a1
 cmp    #$FFFF,(a1)    ;anything else chosen?
 beq    NoSels
 move   (a1),NextM     ;The next menu chosen while holding down the mouse
 move   #1,NextMSel   ;flag to show that we must process the next menu
NoSels:
 move   d5,d6
 mulu   #12,d5         ;every item has 6 chars for ON and 6 for OFF (6+6=12)
 move   COLUMN1_FLAGS,d4 ;flags to remember the merked menu options
 cmp    #8,d6             ;was it superscript?
 bne    nosup
 bclr   #9,d4        ;then demark the subscript flag
nosup:
 cmp    #9,d6        ;was it subscript?
 bne    nosub
 bclr   #8,d4        ;then demark the superscript flag
nosub:
 move.l #Styles,a5      ;get the start of the style code table
 bchg   d6,d4            ;change the flag.0 for unmarked, 1 for marked
 bne    reverse1          ;if it was 0 send the ON code else the OFF code
 move   d4,COLUMN1_FLAGS  ;save the flags
 adda.l  d5,a5            ;get the address of the code
 bra     print         ;print the ON code
reverse1:
 move   d4,COLUMN1_FLAGS
 adda.l d5,a5
 adda.l #6,a5    ;the OFF code is 6 chars after the ON
 bra    print    ;print the OFF code

Character_Column:
 move   d7,d6
 lsr    #5,d6
 andi   #$3f,d6
 move   #1,flag
 move   #1,charset   ;charset shows that char.set has been chosen
 move   d6,d5
 lea    menu21,a1
 mulu   #34,d6
 add    #32,d6
 adda.l d6,a1
 cmp    #$FFFF,(a1)
 beq    NoSelc
 move   (a1),d6
 andi   #$1f,d6      ;d6 has the menu column number
 cmp    #$1,d6       ;the other chosen menu was in another column?
 bne    SomeOtherM     ;yes!
 move   (a1),d7
 bra    Character_Column    ;send only the last char set chosen!
SomeOtherM:
 move   (a1),NextM     ;The next menu chosen while holding down the mouse
 move   #1,NextMSel
NoSelc:
 move   d5,d6
 mulu   #6,d5            ;every option has 6 chars (no OFF code)
 move.l #Characters,a5   ;get the code table start address
 adda.l d5,a5
 move.l #menu21,a4     ;start of menu staructures
 move   d6,d4
 mulu   #34,d4        ;the structures length is 34 Bytes
 add    #12,d4        ;the requiered Byte is the 12th
 adda.l d4,a4
 bset   #8,(a4)             ;set the CHECKED bit
 bra    print             ;send the code for the character set

Control_Column:
 move   #0,charset
 move   d7,d6
 lsr    #5,d6
 andi   #$3f,d6
 move   d6,d5
 lea    menu31,a1
 mulu   #34,d6
 add    #32,d6
 adda.l d6,a1
 cmp    #$FFFF,(a1)
 beq    NoSelcon
 move   (a1),NextM     ;The next menu chosen while holding down the mouse
 move   #1,NextMSel
NoSelcon:
 move   d5,d6
 cmp    #6,d5      ;Reset was chosen?
 beq    MReset      ;yes then clear checked menu items
 cmp    #5,d5       ;Initilise chosen?
 beq    MInitialize   ;yes then clear some menu items
GoOn:
 mulu   #12,d5
 move   COLUMN3_FLAGS,d4
 move.l #Controls,a5
 bchg   d6,d4
 bne    reverse3
 move   d4,COLUMN3_FLAGS
 adda.l d5,a5
 bra    print
reverse3:
 move   d4,COLUMN3_FLAGS
 adda.l d5,a5
 adda.l #6,a5
 bra    print

Print_Column:
 move   d7,d6
 lsr    #5,d6
 andi   #$3f,d6
 cmp    #1,d6
 beq    LINE
FILE:
 lea    FPROMPT,a1    ;write 'Enter File...'
 jsr    Prompting
A_FILE:
 jsr    Find_Event
 jsr    UpDate
 move.l Event,a0
 move.l $14(a0),d6
 cmp    #$40,d6         ;gadget was chosen?
 bne    A_FILE
 move.l $1c(a0),d6
 jsr    Reply
 move.l Event2,Event
 cmp.l  #GADOK,d6
 beq    Process_File_Print
 cmp.l  #GADNO,d6
 beq    ClearP             ;NO selected.clear the prompt and goto loop
 bra    A_FILE
LINE:
 lea    LPROMPT,a1      ;write 'Enter Line:'
 jsr    Prompting
A_LINE:
 jsr    Find_Event
 jsr    UpDate
 move.l Event,a0
 move.l $14(a0),d6
 cmp    #$40,d6      ;a gadget was chosen?
 bne    A_LINE
 move.l $1c(a0),d6
 jsr    Reply
 move.l Event2,Event
 cmp.l  #GADOK,d6     ;was it OK?
 beq    OKSELECT
 cmp.l  #GADNO,d6    ;or maybe NO?
 beq    ClearP
 bra    A_LINE
OKSELECT:
 lea    Busy,a1      ;write 'Please Wait...'
 jsr    Prompting
 tst    Number        ;is there any input?
 beq    Clearp
 clr.l  d3
 move   Number,d3     ;Number is the number of chars in gadget
 lea    Buffer,a3     ;start of chars in gadget
 adda.l d3,a3        ;get the end of buffer
 move.b #10,(a3)+       ;add Line Feed
 move.b #13,(a3)           ;and FormFeed
 move   COLUMN1_FLAGS,d5
 btst   #1,d5             ;Underline is ON?
 beq    No_Space ;no,otherwise we should first turn it off,print the leading
          ; spaces,turn the underline on,and print the non-space characters
 tst.l  Spaces      ;is there spaces at the begining of the text in gadget?
 beq    No_Space    ;no,so no need to send underline off code to the printer
 jsr    OpenPrinter
 move.l d0,PRT_Handler
 bne    OKSEL
 lea    Menu_Bars,a1   ;printer didn't open!
 jsr    Prompting
 move   #1,d0
 bra    PRT_FAILED
OKSEL:
 lea    Styles,a5
 adda.l #18,a5
 move   #1,UnderFlag
 jsr    Prin            ;turn the UnderLine OFF
 jsr    OpenPrinter
 move.l d0,PRT_Handler
 bne    Open1
 lea    Menu_Bars,a1
 jsr    Prompting
 move   #0,UnderFlag
 move   #1,d0
 bra    PRT_FAILED
open1:
 move.l PRT_Handler,d1
 move.l DOS_Base,a6
 move.l #SPC,d2
 move.l Spaces,d3
 jsr    Write(a6)       ;write spaces
 jsr    ClosePrinter
 jsr    OpenPrinter
 move.l d0,PRT_Handler
 bne    Open2
 lea    Menu_Bars,a1
 jsr    Prompting
 move   #0,UnderFlag
 move   #1,d0
 bra    PRT_FAILED

Open2:
 move.l #Styles,a5
 add.l  #12,a5
 jsr    Prin           ;turn the UnderLine ON
 move   #0,UnderFlag
 move.l #buffer,d4     ;get the buffer address
 add.l  Spaces,d4      ;advance it so tahat spaces won't print
 move   Number,d3
 sub.l  Spaces,d3     ;sub number of spaces from the total number of chars
 bra    Skip         ;jump the following line so that parameters won't change
No_Space:
 move   Number,d3     ;print the whole buffer
 move.l #Buffer,d4
Skip:
 add.l  #1,d3
 jsr    OpenPrinter
 move.l d0,PRT_Handler
 bne    Open3
 lea    Menu_Bars,a1
 jsr    Prompting
 move   #0,UnderFlag
 move   #1,d0
 bra    PRT_FAILED
Open3:
 move.l PRT_Handler,d1
 move.l DOS_Base,a6
 move.l d4,d2
 jsr    Write(a6)      ;write line
 jsr    ClosePrinter
 bra    LINE

StandBy_Column: ;closes the window and opens a small one waiting for a click
Close_Window:
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 jsr    CloseWindow(a6)
FirstStart:                   ;here is where we jump at the begining
Window_Openung2:
 move.l Intuition_Base,a6
 lea    Small_Window_Parameters,a0
 jsr    OpenWindow(a6)
 move.l d0,Small_Window_Handler
 beq    Close_DOS
 move.l ExecBase,a6
 move.l Small_Window_Handler,a0
 move.l 86(a0),a0
 jsr    WaitPort(a6)    ;wait!
 move.l ExecBase,a6
 move.l Small_Window_Handler,a0
 move.l 86(a0),a0
 jsr    GetMsg(a6)
 move.l d0,a1
 jsr    ReplyMsg(a6)

WindowClosing:                ;we got the click!. close the window
 move.l #0,Buffer
 move.l Intuition_Base,a6
 move.l Small_Window_Handler,a0
 jsr    CloseWindow(a6)
 bra    Window_Opening

Process_File_Print:
 lea    Busy,a1
 jsr    Prompting
 tst    Number
 beq    Clearp
 jsr    OpenPrinter
 move.l d0,PRT_Handler
 bne    proc
 lea    Menu_bars,a1          ;Could NOT Open Printer!
 jsr    Prompting
 move   #1,d0
 bra    PRT_FAILED
proc:
 move.l DOS_Base,a6    ;opening  requested file
 move.l #Buffer,d1    ;buffer holds the file's name
 move.l #1005,d2
 jsr    Open(a6)
 move.l d0,FileHd
 bne    Reading
 lea    Menu_bars,a1   ;could not open file!
 jsr    Prompting
 bra    No_File
Reading:
 move.l DOS_Base,a6
 move.l FileHd,d1
 move.l #512,d3         ;read 512 Bytes at a time
 move.l #ReadBuffer,d2
 jsr    Read(a6)
 cmp    #0,d0              ;any thing read?
 beq    Exit_File_Print   ;no then exit
 move.l DOS_Base,a6
 move.l PRT_Handler,d1    ;write
 move.l #ReadBuffer,d2
 move.l d0,d3
 jsr    Write(a6)
 bra    Reading
Exit_File_Print:
 move.l FileHd,d1
 move.l DOS_Base,a6
 jsr    Close(a6)
 jsr    ClosePrinter
 bra    clearp

Print:                  ;send code to printer
 lea    Busy,a1      ;write 'Please Wait...'
 jsr    Prompting
 jsr    OpenPrinter
 move.l d0,PRT_Handler
 bne    Prn
 tst    charset         ;charset has been chosen?
 beq    not_C2
 move   #0,flag
not_C2:
 lea    Menu_bars,a1
 jsr    Prompting
 move   #0,d0
 bra    PRT_FAILED
Prn:
 tst    charset
 beq    Prin
 move   d6,last  ;save the last character set, in case we could not send a 
                   ;new character code we must restore it with the old one
Prin:
 move.l PRT_Handler,d1
 move.l DOS_Base,a6
 move.l a5,d2
 move.l #6,d3        ;write 6 chars
 jsr    Write(a6)
 jsr    ClosePrinter
 move   UnderFlag,d1    ;entered to turn the UnderLine code ON or OFF?
 beq    ProcessNext
 rts             ;yes.we called prin with jsr so:RTS!

ClearP:
 lea    Menu_bars,a1
 jsr    Prompting
 bra    loop

No_Menu_Allowed: ;this routine restores menu checkmarks to their original
           ; state when the chosen codes could not be sent to the  printer
 tst    d0
 beq    No_M
 rts
No_M:
 move   d7,d6
 andi.l #$1f,d6
 cmp    #$0,d6
 beq    C1
 cmp    #$1,d6
 beq    C2
 cmp    #$2,d6
 beq    C3
 rts     ;columns 4 print and stand by don't need changes
C1:
 move   d7,d6
 lsr    #5,d6
 andi.l #$3f,d6
 mulu   #34,d6       ;menu structures are 34 Bytes
 lea    menu11,a0     ;menu structure address
 adda.l d6,a0
 adda.l #12,a0
 bchg   #8,(a0)     ;change the CHECKED bit (if ON then OFF,if OFF then ON)
 rts        ;restore menu with new data
C2:
 move   d7,d6
 lsr    #5,d6
 andi.l #$3f,d6
 mulu   #34,d6
 lea    menu21,a0
 adda.l d6,a0
 adda.l #12,a0
 bclr   #8,(a0)
 tst    flag        ;have we ever entered the character set column?
 bne    changed
 rts
changed:           ;yes!
 move   last,d6
 mulu   #34,d6
 lea    menu21,a0
 adda.l d6,a0
 adda.l #12,a0
 bset   #8,(a0)
 rts
C3:
 move   d7,d6
 lsr    #5,d6
 andi   #$3f,d6
 mulu   #34,d6
 lea    menu31,a0
 adda.l d6,a0
 adda.l #12,a0
 bchg   #8,(a0)
 rts

SetM:
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 lea    Menu_Structure,a1
 jsr    SetMenuStrip(a6)
 rts

CLRMenu:
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 jsr    ClearMenuStrip(a6) 
 rts

MReset:                     ;clears check marked menus
 move.l #10,d2              ;column 1 and 2 have 11 items
 move   #0,COLUMN1_FLAGS
 lea    menu11,a5
 lea    menu21,a6
 adda.l #12,a5
 adda.l #12,a6
Mclear:               ;in this loop CHECKED is cleared
 bclr   #8,(a5)
 bclr   #8,(a6)
 adda.l #34,a5
 adda.l #34,a6
 dbra   d2,Mclear
 move   #0,COLUMN3_FLAGS
 lea    menu31,a5
 adda.l #12,a5      ;in column 3 'NLQ' and '1/8 inch ...' are cleared
 bclr   #8,(a5)
 adda.l #102,a5
 bclr   #8,(a5)
 bra    GoOn

MInitialize:               ;clears some menu items in the first column
 move.l #6,d2               ;clear 7 items
 andi   #%1111111110000000,COLUMN1_FLAGS  ;item number 0,1,..,8
 lea    menu11,a5
 adda.l #12,a5
MIclear:          ;this loop clears the CHECKED bits
 bclr   #8,(a5)
 adda.l #34,a5
 dbra   d2,MIclear
 move   #0,COLUMN3_FLAGS
 lea    menu31,a5          ;also clear the 'NLQ' and '1/8 inch...'
 adda.l #12,a5
 bclr   #8,(a5)
 adda.l #102,a5
 bclr   #8,(a5)
 bra    GoOn

SI:                           ;prints text at specified position.
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 move.l 50(a0),a0
 jsr    PrintIText(a6)
 rts

Find_Event:
 move.l Event,Event2
 move.l ExecBase,a6
 move.l Window_Handler,a0
 move.l 86(a0),a0
 jsr    WaitPort(a6)
 move.l ExecBase,a6         ;event happened
 move.l Window_Handler,a0
 move.l 86(a0),a0
 jsr    GetMsg(a6)      ;get the event
 move.l d0,Event      ;save it
 rts

Reply:
 move.l ExecBase,a6
 move.l Event,a1
 jsr    ReplyMsg(a6)
 rts

PRT_FAILED:                ;handles printer open failers
 jsr    No_Menu_Allowed     ;restore menus
 move.l Intuition_Base,a6
 move.l ScreenHd,a0
 jsr    DisplayBeep(a6)   ;flash the screen
 move.l #PRT_F,bodyt
 move.l #Canceling,leftt
 jsr    Requester         ;inform that printer could not be opened
 bra    ProcessNext

NO_FILE:                  ;handles file open failers
 jsr    ClosePrinter
 move.l Intuition_Base,a6
 move.l ScreenHd,a0
 jsr    DisplayBeep(a6)
 move.l #NO_F,bodyt
 move.l #Canceling,leftt
 jsr    Requester        ;inform that file could not be opened
 bra    loop


OpenPrinter:
 move.l DOS_Base,a6
 lea    PRT_Name,a1
 move.l #1006,d0
 move.l a1,d1
 move.l d0,d2
 jsr    Open(a6)
 rts

ClosePrinter:
 move.l DOS_Base,a6
 move.l PRT_Handler,d1
 jsr    Close(a6)
 rts

Prompting:         ;writes message text,like SI routine but at fixed pos.
 move.l #12,d0              ;X pos.
 move.l #11,d1              ;Y pos.
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 move.l 50(a0),a0
 jsr    PrintIText(a6)
 rts

ProcessNext:      ;process the next menu while holding down the right mouse
 tst    NextMSel     ;is there another menu to process?
 bne    HasNext       ;yes!
 bra    clearp
HasNext:
 move   NextM,d7
 move   #0,NextMSel
 bra    Real_Selection

Requester:
 move.l Window_Handler,a0
 lea    btext,a1
 lea    ltext,a2
 lea    rtext,a3
 move.l #0,d0
 move.l #0,d1
 move.l #300,d2
 move.l #60,d3
 move.l Intuition_Base,a6
 move.l #Canceling,rightt
 jsr    AutoRequest(a6)
 rts

UpDate:             ;update the start and end column
 lea    BufferE,a1
 clr.l  d0
 move   Number,d0
 beq    Zero         ;no entry in the gadget!
 sub    #1,d0
 jsr    B2A         ;convert Binary to Decimal
 clr.l  d2
 move   Number,d2
 sub    #1,d2
 lea    Buffer,a1
 move.l #-1,d0
StF:
 add.l  #1,d0
 cmpi.b #" ",(a1)+     ;spaces at the start of the text?
 dbne   d2,StF
 lea    BufferS,a1
 move.l d0,Spaces     ;number of spaces
 jsr    B2A
 lea    BufS,a1       ;write start column number
 move.l #180,d0
 move.l #56,d1
 jsr    SI
 lea    BufE,a1      ;write end column number
 move.l #305,d0
 move.l #56,d1
 jsr    SI
 rts

Zero:                 ;no entry in gadget,print '???'
 lea    Unknown,a1
 move.l #180,d0
 move.l #56,d1
 jsr    SI
 lea    UnKnown,a1
 move.l #305,d0
 move.l #56,d1
 jsr    SI
 rts

B2A:            ;this routine converts binary to ASCII and stores them 
                ;in string starting with a1
 move.l #16,d2     ;must use 16 bit shifts!
 divu   #100,d0    ;divide by 100,the quotient is the 100th number
 move   d0,d1
 add    #48,d1     ;in ASCII 0 begins at the 48th char
 move.b d1,(a1)+   ;store it as a char
 lsr.l  d2,d0      ;shift the d0 to have the remainder in low bits
 divu   #10,d0     ;divide by 10
 move   d0,d1
 add    #48,d1
 move.b d1,(a1)+
 lsr.l  d2,d0
 cmp    #10,d0
 bne    add48
 add    #1,d0
 add.b  #1,$-1(a1)
add48:
 add    #48,d0
 move.b d0,(a1)+
 move.b #0,(a0)   ;write NULL to end the string
 rts

End_Requested:          ;user clicked on the close gadget ,verify the quit
 move.l #endbodyt,bodyt
 move.l #Ofcourse,leftt
 move.l #Canceling,rightt
 jsr    requester
 tst.l  d0          ;left or right choice?
 beq    loop         ;it was the right one (Cancel)
 jsr    Reply
 move.l #0,DOSResult
Clear_Menu:             ;it was the left one ,we must close system resources
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 jsr    ClearMenuStrip(a6)

Close_Big_Window:
 move.l Intuition_Base,a6
 move.l Window_Handler,a0
 jsr    CloseWindow(a6)

Close_DOS:
 move.l ExecBase,a6
 move.l DOS_Base,a1
 jsr    CloseLib(a6)

Close_Intuition:
 move.l ExecBase,a6
 move.l Intuition_Base,a1
 jsr    CloseLib(a6)
 move.l DOSResult,d0
 rts                  ;end of the program!

DECLARATIONS:

Libraries:
DOS_Name:             dc.b "dos.library",0
Intuition_Name:       dc.b "intuition.library",0
DOS_Base:             dc.l 0
Intuition_Base:       dc.l 0
PRT:
PRT_Name:             dc.b "PRT:",0,0
PRT_Handler:          dc.l 0
FontName:             dc.l FontStr
                      dc.l 524288
FontStr:              dc.b "topaz.font",0,0
Window:
Window_Handler:       dc.l 0
Window_Name:          dc.b "Printer Controller",0,0
Small_Window_Handler: dc.l 0
Small_Window_Name:    dc.b "PC",0,0
FileHd:               dc.l 0
ReadBuffer:           blk.b 512
Buffer:               blk.b 136,0
UnDo:                 blk.b 136,0
Buffer4:              blk.b 4,0
Canceling:            dc.b "Cancel",0,0
PRT_F:                dc.b " Can NOT Open Printer!",0,0
NO_F:                 dc.b " Can NOT Open File!",0
endbodyt:             dc.b " Realy Want to Quit?",0,0
Ofcourse:             dc.b "Ofcourse!",0
Event:                dc.l 0
Event2:               dc.l 0
DOSResult:            dc.l 0
flag:                 dc.w 0
charset:              dc.w 0
last:                 dc.w 0
Spaces:               dc.l 0
UnderFlag:            dc.w 0
NextM:                dc.w 0
NextMSel:             dc.w 0
SPC:                  blk.b 132,32
COLUMN1_FLAGS:        dc.w 0
COLUMN3_FLAGS:        dc.w 0

Window_Parameters:
 dc.w 0,0,630,80
 dc.b 0,1
 dc.l $360
 dc.l $100e
 dc.l GADGET_DEF
 dc.l 0
 dc.l Window_Name
ScreenHd:
 dc.l 0
 dc.l 0
 dc.w 630,50,640,512
 dc.w 1

Small_Window_Parameters:
 dc.w 290,25,43,30
 dc.b 0,1
 dc.l $40
 dc.l $1002
 dc.l GADGET2_DEF
 dc.l 0
 dc.l Small_Window_Name
ScreenHd2:
 dc.l 0
 dc.l 0
 dc.w 630,50,640,512
 dc.w 1

REQUEST:
btext:
 dc.b 2,1,0,0 ;the last zero is a pad 
 dc.w 10,10
 dc.l FontName
bodyt:
 dc.l 0,0

ltext:
 dc.b 2,1,0,0  ;the last zero is a pad
 dc.w 5,3
 dc.l FontName
leftt:
 dc.l 0,0

rtext:
 dc.b 2,1,0,0
 dc.w 5,3
 dc.l FontName
rightt:
 dc.l 0,0

GADGET:
GADGET_DEF:
 dc.l GADOK
 dc.w 10,40,610,9
 dc.w 0
 dc.w 3
 dc.w 4
 dc.l BORDER_DEF
 dc.l 0,0,0
 dc.l STR_INFO
 dc.w 2
 dc.l 0

GADGET2_DEF:
 dc.l 0
 dc.w 5,12,35,15
 dc.w 5
 dc.w 3
 dc.w 1
 dc.l image22
 dc.l 0,0,0,0
 dc.w 1
 dc.l 0

BORDER_DEF:
 dc.w 0,0
 dc.b 3,0,0,5
 dc.l CoOrdination
 dc.l Border_Def2

CoOrdination:
 dc.w -2,-2,610,-2,610,9,-2,9,-2,-2

Border_Def2:
 dc.w 0,0
 dc.b 3,0,0,5
 dc.l CoOrdination2
 dc.l 0

CoOrdination2:
 dc.w -4,-3,612,-3,612,10,-4,10,-4,-3

STR_INFO:
 dc.l Buffer
 dc.l UnDo
 dc.w 0
 dc.w 133
 dc.w 0,0
Number:
 dc.w 0,0,0,0
 dc.l 0,0
 dc.l 0

GADOK:
 dc.l GADNO
 dc.w 40,59,32,13
 dc.w 5
 dc.w 3
 dc.w 1
 dc.l image1
 dc.l 0,0,0,0
 dc.w 1
 dc.l 0

GADNO:
 dc.l 0
 dc.w 540,59,32,13
 dc.w 5
 dc.w 3
 dc.w 1
 dc.l image2
 dc.l 0,0,0,0
 dc.w 3
 dc.l 0

image1:
 dc.w 0,0,32,13
 dc.w 1
 dc.l imgdata1
 dc.b 2,1
 dc.l 0

imgdata1:
 dc.l %00000000000000000000000000000000
 dc.l %00001111111000000111100011100000
 dc.l %00111000001110000011100011100000
 dc.l %00111000001110000011100111000000
 dc.l %00111000001110000011101110000000
 dc.l %00111000001110000011111100000000
 dc.l %00111000001110000011111100000000
 dc.l %00111000001110000011100111000000
 dc.l %00111000001110000011100011100000
 dc.l %00111000001110000011100001110000
 dc.l %00111000001110000011100001110000
 dc.l %00001111111000000111100001110000
 dc.l %00000000000000000000000000000000

image2:
 dc.w 0,0,32,13
 dc.w 1
 dc.l imgdata2
 dc.b 2,1
 dc.l 0

imgdata2:
 dc.l %00000000000000000000000000000000
 dc.l %00111000000011100000111111100000
 dc.l %00111100000011100011100000111000
 dc.l %00111111000011100011100000111000
 dc.l %00111011100011100011100000111000
 dc.l %00111001110011100011100000111000
 dc.l %00111000111011100011100000111000
 dc.l %00111000011111100011100000111000
 dc.l %00111000001111100011100000111000
 dc.l %00111000000111100011100000111000
 dc.l %00111000000011100011100000111000
 dc.l %00111000000011100000111111100000
 dc.l %00000000000000000000000000000000

image22:
 dc.w 0,0,32,15
 dc.w 1
 dc.l imgd22
 dc.b 2,1
 dc.l 0

imgd22:
 dc.l %00000000000000010000000000000000
 dc.l %00000000000001111100000000000000
 dc.l %00000000000011010110000000000000
 dc.l %00000000000110010011000000000000
 dc.l %00011000000000010000000000011000
 dc.l %00110000000000010000000000001100
 dc.l %01100000000000111000000000000110
 dc.l %11111111111111111111111111111111
 dc.l %01100000000000111000000000000110
 dc.l %00110000000000010000000000001100
 dc.l %00011000000000010000000000011000
 dc.l %00000000000110010011000000000000
 dc.l %00000000000011010110000000000000
 dc.l %00000000000001111100000000000000
 dc.l %00000000000000010000000000000000


Border1:
 dc.w 0,0
 dc.b 3,0,0,5
 dc.l CoOrd1
 dc.l Border2
CoOrd1:
 dc.w -2,0,25,0,25,9,-2,9,-2,0

Border2:
 dc.w 125,0
 dc.b 3,0,0,5
 dc.l CoOrd2
 dc.l Border3
CoOrd2:
 dc.w -2,0,25,0,25,9,-2,9,-2,0

Border3:
 dc.w -170,-45
 dc.b 3,0,0,5
 dc.l CoOrd3
 dc.l 0
CoOrd3:
 dc.w 0,0,210,0,210,9,0,9,0,0

LPROMPT:
 dc.b 1,2,1,0 ;the last zero is a pad
 dc.w 10,10
 dc.l FontName,textl,0
textl:           dc.b " Enter Line:              ",0,0
FPROMPT:
 dc.b 1,2,1,0
 dc.w 10,10
 dc.l FontName,textf,0
textf:           dc.b " Enter File Path and Name:",0,0
Menu_Bars:
 dc.b 1,2,1,0
 dc.w 10,10
 dc.l FontName,textn,0
textn:           dc.b " Choose From Menu Bars!   ",0,0
Intro:
 dc.b 1,2,1,0
 dc.w 10,10
 dc.l FontName,texti,0
texti:           dc.b " By Kamran Karimi         ",0,0
Busy:
 dc.b 1,2,1,0
 dc.w 10,10
 dc.l FontName,textb,0
textb:           dc.b " Please Wait...           ",0,0
BufE:
 dc.b 1,2,1,0
 dc.w 10,10
 dc.l FontName,BufferE,0
BufferE:         blk.b 4,0
BufS:
 dc.b 1,2,1,0  ;the last zero is a pad
 dc.w 10,10
 dc.l FontName,BufferS,0
BufferS:         blk.b 4,0
Stext:
 dc.b 1,0,1,0
 dc.w 10,10
 dc.l FontName,startt,0
startt:          dc.b "Start Column",0,0
Etext:
 dc.b 1,0,1,0
 dc.w 10,10
 dc.l FontName,Endt,0
Endt:            dc.b "End Column",0,0

UnKnown:
 dc.b 1,2,1,0
 dc.w 10,10
 dc.l FontName,UnKnow,0
UnKnow:            dc.b "???",0

Menu:
Title1:  dc.b "Style",0
Title2:  dc.b "Character Set",0
Title3:  dc.b "Control",0
Title4:  dc.b "Print",0
Title5:  dc.b "Stand By",0
 ds.w 0
  
MI11:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex11,0
tex11: dc.b "  Italics",0
MI12:    dc.b 0,1,0
 ds.w 0      
 dc.w 1,1
 dc.l FontName,tex12,0
tex12: dc.b "  Underline",0
MI13:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex13,0
tex13: dc.b "  Bold",0,0
MI14:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex14,0
tex14: dc.b "  Enlarged",0,0
MI15:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex15,0
tex15: dc.b "  Condensed",0
MI16:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex16,0
tex16: dc.b "  Proportional",0,0
MI17:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex17,0
tex17: dc.b "  Elite",0
MI18:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex18,0
tex18: dc.b "  Doublestrike",0,0
MI19:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex19,0
tex19: dc.b "  Superscript",0
MI110:   dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex110,0
tex110: dc.b "  Subscript",0
MI111:   dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex111,0
tex111: dc.b "  Shadow",0,0
MI21:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex21,0
tex21: dc.b "  U.S",0
MI22:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex22,0
tex22: dc.b "  German",0,0
MI23:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex23,0
tex23: dc.b "  British",0
MI24:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex24,0
tex24: dc.b "  French",0,0
MI25:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex25,0
tex25: dc.b "  Swedish",0
MI26:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex26,0
tex26: dc.b "  Italian",0
MI27:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex27,0
tex27: dc.b "  Spanish",0
MI28:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex28,0
tex28: dc.b "  Norwegian",0
MI29:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex29,0
tex29: dc.b "  Danish I",0,0
MI210:   dc.b 0,1,0
 dc.w 1,1
 dc.l FontName,tex210,0
tex210: dc.b "  Danish II",0
MI211:   dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex211,0
tex211: dc.b "  Japanese",0,0
MI31:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex31,0
tex31: dc.b "  NLQ",0
MI32:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex32,0
tex32: dc.b "  Linefeed",0,0
MI33:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex33,0
tex33: dc.b "  Formfeed",0,0
MI34:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex34,0
tex34: dc.b "  1/8 inch Linespacing",0,0
MI35:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex35,0
tex35: dc.b "  Reverse Linefeed",0,0
MI36:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex36,0
tex36: dc.b "  Initialize",0,0
MI37:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l Fontname,tex37,0
tex37: dc.b "  Reset",0
       
MI41:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l Fontname,tex41,0
tex41: dc.b "   a File",0
MI42:    dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex42,0
tex42: dc.b "   a Line",0
       
MI51:   dc.b 0,1,0,0
 dc.w 1,1
 dc.l FontName,tex51,0
tex51: dc.b "  Please ",0
       
Menu_Structure:
menu1:
 dc.l menu2
 dc.w 15,0
 dc.w 55,10
 dc.w 1
 dc.l Title1
 dc.l menu11
 dc.w 0,0,0,0

menu2:
 dc.l menu3
 dc.w 95,0
 dc.w 135,10
 dc.w 1
 dc.l Title2
 dc.l menu21
 dc.w 0,0,0,0

menu3:
 dc.l menu4
 dc.w 250,0
 dc.w 75,10
 dc.w 1
 dc.l Title3
 dc.l menu31
 dc.w 0,0,0,0

menu4:
 dc.l menu5
 dc.w 350,0
 dc.w 55,10
 dc.w 1
 dc.l Title4
 dc.l menu41
 dc.w 0,0,0,0

menu5:
 dc.l 0
 dc.w 420,0
 dc.w 85,10
 dc.w 1
 dc.l Title5
 dc.l menu51
 dc.w 0,0,0,0

menu11:
 dc.l menu12
 dc.w 0,0,120,10
 dc.w $9b
 dc.l 0,MI11,0
 dc.b 0,0       ;the last zero is pad
 dc.l 0
 dc.w 0
menu12:
 dc.l menu13
 dc.w 0,12,120,10
 dc.w $9b
 dc.l 0,MI12,0
 dc.b 0,0  ;the last zero is pad   
 dc.l 0
 dc.w 0
menu13:
 dc.l menu14
 dc.w 0,24,120,10
 dc.w $9b
 dc.l 0,MI13,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu14:
 dc.l menu15
 dc.w 0,36,120,10
 dc.w $9b
 dc.l 0,MI14,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu15:
 dc.l menu16
 dc.w 0,48,120,10
 dc.w $9b
 dc.l 0,MI15,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu16:
 dc.l menu17
 dc.w 0,60,120,10
 dc.w $9b
 dc.l 0,MI16,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu17:
 dc.l menu18
 dc.w 0,72,120,10
 dc.w $9b
 dc.l 0,MI17,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu18:
 dc.l menu19
 dc.w 0,84,120,10
 dc.w $9b
 dc.l 0,MI18,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu19:
 dc.l menu110
 dc.w 0,96,120,10
 dc.w $9b
 dc.l %01000000000,MI19,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu110:
 dc.l menu111
 dc.w 0,108,120,10
 dc.w $9b
 dc.l %00100000000,MI110,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu111:
 dc.l 0
 dc.w 0,120,120,10
 dc.w $9b
 dc.l 0,MI111,0
 dc.b 0,0   
 dc.l 0
 dc.w 0

menu21:
 dc.l menu22
 dc.w 0,0,130,10
 dc.w $9b
 dc.l %11111111110,MI21,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu22:
 dc.l menu23
 dc.w 0,12,130,10
 dc.w $9b
 dc.l %11111111101,MI22,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu23:
 dc.l menu24
 dc.w 0,24,130,10
 dc.w $9b
 dc.l %11111111011,MI23,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu24:
 dc.l menu25
 dc.w 0,36,130,10
 dc.w $9b
 dc.l %11111110111,MI24,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu25:
 dc.l menu26
 dc.w 0,48,130,10
 dc.w $9b
 dc.l %11111101111,MI25,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu26:
 dc.l menu27
 dc.w 0,60,130,10
 dc.w $9b
 dc.l %11111011111,MI26,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu27:
 dc.l menu28
 dc.w 0,72,130,10
 dc.w $9b
 dc.l %11110111111,MI27,0
 dc.b 0,0    
 dc.l 0
 dc.w 0
menu28:
 dc.l menu29
 dc.w 0,84,130,10
 dc.w $9b
 dc.l %11101111111,MI28,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu29:
 dc.l menu210
 dc.w 0,96,130,10
 dc.w $9b
 dc.l %11011111111,MI29,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu210:
 dc.l menu211
 dc.w 0,108,130,10
 dc.w $9b
 dc.l %10111111111,MI210,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu211:
 dc.l 0
 dc.w 0,120,130,10
 dc.w $9b
 dc.l %01111111111,MI211,0
 dc.b 0,0   
 dc.l 0
 dc.w 0

menu31:
 dc.l menu32
 dc.w 0,0,185,10
 dc.w $9b
 dc.l 0,MI31,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu32:
 dc.l menu33
 dc.w 0,12,185,10
 dc.w $9a
 dc.l 0,MI32,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu33:
 dc.l menu34
 dc.w 0,24,185,10
 dc.w $9a
 dc.l 0,MI33,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu34:
 dc.l menu35
 dc.w 0,36,185,10
 dc.w $9b
 dc.l 0,MI34,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu35:
 dc.l menu36
 dc.w 0,48,185,10
 dc.w $9a
 dc.l 0,MI35,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu36:
 dc.l menu37
 dc.w 0,60,185,10
 dc.w $9a
 dc.l 0,MI36,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu37:
 dc.l 0
 dc.w 0,72,185,10
 dc.w $9a
 dc.l 0,MI37,0
 dc.b 0,0   
 dc.l 0
 dc.w 0

menu41:
 dc.l menu42
 dc.w 0,0,80,10
 dc.w $9a
 dc.l 0,MI41,0
 dc.b 0,0   
 dc.l 0
 dc.w 0
menu42:
 dc.l 0
 dc.w 0,12,80,10
 dc.w $9a
 dc.l 0,MI42,0
 dc.b 0,0   
 dc.l 0
 dc.w 0

menu51:
 dc.l 0
 dc.w 0,0,80,10
 dc.w $9a
 dc.l 0,MI51,0
 dc.b 0,0   
 dc.l 0
 dc.w 0

Styles:
 dc.b 27,91,51,109,0,0,27,91,50,51,109,0,27,91,52,109,0,0,27,91,50,52,109,0
 dc.b 27,91,49,109,0,0,27,91,50,50,109,0,27,91,54,119,0,0,27,91,53,119,0,0
 dc.b 27,91,52,87,0,0,27,91,51,119,0,0
 dc.b 27,91,50,112,0,0,27,91,49,112,0,0,27,91,50,119,0,0,27,91,49,119,0,0
 dc.b 27,91,52,34,122,0,27,91,51,34,122,0,27,91,50,118,0,0,27,91,49,118,0,0
 dc.b 27,91,52,118,0,0,27,91,51,118,0,0,27,91,54,34,122,0,27,91,53,34,122,0

Characters:
 dc.b 27,40,66,0,0,0,27,40,75,0,0,0
 dc.b 27,40,65,0,0,0,27,40,82,0,0,0
 dc.b 27,40,72,0,0,0,27,40,89,0,0,0
 dc.b 27,40,90,0,0,0,27,40,54,0,0,0 
 dc.b 27,40,69,0,0,0
 dc.b 27,40,67,0,0,0,27,40,74,0,0,0

Controls:
 dc.b 27,91,50,34,122,0,27,91,49,34,122,0,27,68,0,0,0,0,27,68,0,0,0,0
 dc.b 12,0,0,0,0,0,12,0,0,0,0,0,27,91,48,122,0,0,27,91,49,122,0,0
 dc.b 27,77,0,0,0,0,27,77,0,0,0,0,27,35,49,0,0,0
 dc.b 27,35,49,0,0,0,27,99,0,0,0,0,27,99,0,0,0,0

 end

