Wait_Trace: push dx move.w #$3da, dx ;Wait for the vertical trace. _wait_lp1: in.b dx, a ;Wait for retrace to start. and.b #8, a ;Quicker than 'test' on older machines. bne.s _wait_lp1 ;Twiddle your thumbs awhile. _wait_lp2: in.b dx, a and.b #8, a beq.s _wait_lp2 ;Wait for retrace to finish. pop dx rts ***************************************************************************** Get_KeyStroke: push si push di push ds push bx cs:lds KeyMem, si eor.w ax, ax move.w (si), di cmp.w 2(si), di ;Check if a key was pressed. beq.s Exit_KeyStroke ;Definitely, Maybe not. move.w (di), bx ;Get the KeyStroke data. lea 2(di), di ;Reset the header. move.w di, (si) ; cmp.w #$3c, di ; ble.s Print_KeyStroke ; move.w #$1e, (si) ; Print_KeyStroke: push bx ; push cx ; cs:les KeyPrint, di ; move.b #!BC, ah ; move.b #4, cl ; bsr.w Print_Hex ; pop cx ; pop ax ; Exit_KeyStroke: pop bx pop ds pop di pop si rts *-+-* KeyMem dc.w $001a, $0040 KeyPrint dc.w $0F96, $B800 ***************************************************************************** _Save_Palette: push cs ; pop es ;Set the segment register. move.w #SPALETTE, di :Where to save the data. move.w #6*3, cx ;The count. eor.b al, al ;The first colour to save. bsr.w _Load_Palette move.w #3, cx ; move.b #20, al ;The odd one. bsr.w _Load_Palette move.w #3, cx ; move.b #7, al ; bsr.w _Load_Palette ; move.w #7*3, cx ;The count. move.b #56, al ;The save position. _Load_Palette: move.w #$3c7, dx ;The hardware address. out.b al, dx ;Tell the hardware. add.w #2, dx ;Move to the data send. _Load_Loop: rep ins.b ;Save the palette. rts ***************************************************************************** _Set_Palette: push cs ;Set the segment. pop ds ; _Set2: move.w #6*3, cx ;The count. eor.b al, al ;The start position. bsr.w _Send_Palette :Set the palette. move.w #3, cx ; move.b #20, al ;The odd one. bsr.w _Send_Palette ;Set it. move.w #3, cx ; move.b #7, al ; bsr.w _Send_Palette ; move.w #7*3, cx ;The new Count. move.b #56, al ;The new position. _Send_Palette: cli ;Disable interrupts. move.w #$3c8, dx ;The hardware address. out.b dx, al ;Send the mode data. inc.w dx rep outs.b sti rts ***************************************************************************** Get_Arguements: push ds push es cs:move.w PSPSegment, ds ;Set the DS. cs:move.w CodeSegment, es ;Set the ES. *-+-* move.w #$81, si ;Where to get the data from. move.w #Filename, di ;Where to store the filename. eor.b ah, ah ;Set that no arguements processed. bra.s _Arg_Loop ;Start the fetch. _Loop_Start: inc.b ah ;Set that an arguement processed. stos.b ;Store the byte. _Arg_Loop: lods.b ;Get the next byte. cmp.b #$D, al ;Check for carriage return. beq.s _Arg_Done ;Yes, end of the line. cmp.b #$20, al ;Is it a space? bne.s _Loop_Start ;Yes, so skip it. or.b ah, ah ;An arguement processed already? beq.s _Arg_Loop ;No, so skip leading blanks. *-+-* _Arg_Done: cs:move.w #$0024, 1(di) ;Terminate the filename string. move.w #Arguements+2, di ;Where to store the arguements. move.w #$2000, cx ;Set the count to zero. lea -1(si), si ;Move back one. _Copy_Arg: movs.b ;Copy the byte across. ds:cmp.b #$D, -1(si) ;Are we at the end of the line? beq.s _Exit_Arg ;Yes, so quit all this. inc.b cl ;Add 1 to the count. bra.s _Copy_Arg ;Get the next byte. _Exit_Arg: cs:move.w cx, Arguements ;Save the count. cs:move.w #Arguements, CmdLine ; cs:move.w cs, CmdLine+2 ; *-+-* pop es pop ds rts ***************************************************************************** Load_EXE: push es ;Save ES. push ds ;Save DS. move.w cs, ax move.w ax, es move.w ax, ds cs:move.b #0, Program move.w #$4b01, ax move.w #Filename, dx move.w #ParamBlock, bx trap #$21 bcs.s _Not_Loaded cs:move.w #$7300, S_FLAGS ;Set the FLAGS. cs:move.w ax, CursorPos ;Set the cursor position. cs:move.b #!PROG_PAWS, Program ;Set program as loaded. cs:move.l CS_IP, a ;Load the Instruction pointer. cs:move.l a, HexSource ;Set the hex screen address. cs:move.w a, HexCursor ;Set the hex cursor position. cs:move.l a, CodSource ;Set the dissassembly address. cs:push.l SS_SP ;Load the stack pointer. cs:pop.w S_SP ;Save the offset. cs:pop.w S_SS ;Save the segment. cs:move.w ax, S_IP ;Set up the program stack. shr.l #16, a ; future use... move.w ax, S_CS ; !!!! move.w #$5100, ax ;Get the PSP segment of the trap #$21 ;loaded program. cs:move.w bx, S_PSP ; cs:move.w bx, S_DS ; Save the PSP in the cs:move.w bx, S_ES ; appropriate registers. move.w bx, ds ; ----------------------- ds:move.w cs, $000C ; Set the programs EXIT. ds:move.w #ChildExit, $000A ; ----------------------- _Not_Loaded: pop ds ;Restore DS. pop es ;and ES. rts ***************************************************************************** HelpScreen: rts ***************************************************************************** * CL -> 0 = Just draw the box and string. * * CL -> 1 = Draw the box and string and wait for any key. * * CL -> 2 = Draw the box and string and wait for Yes or No. * ***************************************************************************** DrawInfoBox: eor.w bx, bx ;Clear BX. move.w dx, di ;Move it to our work area. Info_Loop: cs:cmp.b #0, (bx, di) ;Are we at the end of the string? beq.s Length_Found ;Yes, so quit. inc.w bx ;No, increment the count... bra.s Info_Loop ;Search next. Length_Found: push.w cx ;Save the get mode. push.w dx ;Save the string. move.w bx, cx ;Put it in it's place. add.w #2, cx ;Create a space either side. move.w #1, bx ;Set the depth count. move.b #!BC, ah ;Set the colour. bsr.w DrawBox ;Draw the box. pop.w dx ;Pop the string. move.b #!BH, ah ;The colour. bsr.w Print_String ;Print the string. pop.w cx ;Pop the key mode. or.b cl ,cl ;Check just quit. beq.s InfoExit InfoWait: bsr.w Get_KeyStroke ;Get a keystroke. or.w ax, ax ;Check for zero entry. beq.s InfoWait cmp.b #1, cl ;Check for any key. beq.s InfoExit ;Yep. and.b #$DF, al ;Mask off the bits. cmp.b #'Y', al ; beq.s InfoExit cmp.b #'N', al bne.s InfoWait InfoExit: rts ***************************************************************************** * : * ***************************************************************************** DrawBox: push.w ax ;Save AX. push.w cx ;Save it. move.w #24, ax ; sub.w bx, ax ; shr.w #1, ax ; move.w ax, di ; shl.w #2, di ; add.w ax, di ; shl.w #5, di ; move.w #80, ax ; sub.w cx, ax ; add.w ax, di ; and.w #$FFFE, di ;Keep it crisp and even. pop.w cx pop.w ax DrawImdBox: push.w di ;Save the screen position. move.b #201, al ;The top left corner. stos.w ;Print it. move.w di, dx ; add.w #162, dx ;The first byte inside the box. move.b #205, al ;An horizontal line. push.w cx ;The Width. repne ;Print a line. stos.w ;Print it. pop.w cx ;Restore the width. move.b #187, al ;Top right corner. stos.w ;Print it. _Line_Loop: pop.w di ;Pop it. lea 160(di), di ;Move to the next line. push.w di ;Save it. move.b #186, al ;Load AX. stos.w ;Print a vertical line. push.w cx :Save the width, move.b #32, al :Print Spaces. repne ;Repeat... stos.w ;Print a load of filling spaces. pop.w cx ;Restore CX. move.b #186, al ;Pre-load AX. stos.w ;Print right vertical line. dec.w bx ;Move down a line bne.s _Line_Loop pop di ; lea 160(di), di ;Move next... move.b #200, al ;The bottom left corner. stos.w ;Print it. move.b #205, al ;An horizontal line. repne ;Print a line. stos.w ;Print it. move.b #188, al ;The bottom right corner. stos.w ;Print it. move.w dx, di ; rts ***************************************************************************** Update_Bars: move.b #!BC, ah ;Set the colour. move.w #2, di ;Top line start address. move.w #MYINFO, dx ;What to print. bsr.w Print_String ;Print my information. move.w #144, di move.w #CPUID, dx ; bsr.w Print_String move.w #3842, di ;Move to the bottom line. move.w #P_List, si ;Where the text is stored. cs:move.w (si), dx ;Get the first string. bsr.w Print_String ;Print it. cs:move.b Program, bl ;Get the program status. eor.b bh, bh ;Clear the high byte. shl.b #1, bl ;Multiply by 2. cs:move.w 2(bx,si), dx ;Get the string. bsr.w Print_String move.b #$20, al ;Print a space. stos.w ; * cs:cmp.b #!PFINISHED, Program ;Program done for? * bne.s _Check4Prog :No, so check if we have a filename. * bra.s _ClearLine ;Done. _Check4Prog: cs:cmp.b #0, Filename ;Check if we have a filename. beq.s _ClearLine ; move.b #'[', al ; stos.w ;Print left bracket. move.w #Filename, dx ;Get the filename. bsr.w Print_String move.b #']', al stos.w ;Print right bracket. _ClearLine: move.b #$20, al ;Set up AL. _ClearLoop: stos.w ;Erase any data on the line. es:cmp.b #$20, 1(di) ;Check for more rubbish. bne.s _ClearLoop ;Clear more rubbish. _Skip_File: rts ***************************************************************************** PrintHexCol: push.w cx ; asl.b #3, cl ; We are printing backwards:- dc.b $66 ; ror.w cl, bx ; to the front of the queue. pop.w cx ; HexSetCol: move.b #2, ch ;Number of nibbles to print. move.b #!HEX_COLB, ah ;Set the intial colour. es:cmp.b ah, -3(di) ;Check if it was the last colour. bne.s HexCol_lp ;Colour ok. move.b #!HEX_COLA, ah :Set the other colour. HexCol_lp: dc.b $66 rol.w #4, bx ; Move to the first nibble. move.b bl, al ; and.b #$f, al ; Mask it off. add.b #$30, al ; cmp.b #$39, al ; ble.s Col_Char ; add.b #7, al ; Col_Char: stos.w ; Print the hex character. dec.b ch ; Decrement the count. bne.s HexCol_lp ; Loop again if not zero. dec.b cl ; bne.s HexSetCol ; rts *****************************************************************************