***************************************************************************** Move_Cursor: cs:move.w 4(si), ax ;Get the in/decrement. push.w ax ;Save the (De/In)crement. cs:lds HexSource, si ;Get the screen position. cs:move.w HexCursor, bx ;Get the cursor position. or.w ax, ax ;Clear AX. bpl.s _Cursor_Down ;Going up or down? neg.w ax ;We want to see if the difference sub.w si, bx ;between the screen start and the cmp.w bx, ax ;cursor position is less than the ble.s _On_Screen ;amount we want to move up the bra.s _Off_Screen ;screen. _Cursor_Down: sub.w si, bx move.w #!TOTALCHARS, cx sub.w bx, cx cmp.w cx, ax blt.s _On_Screen _Off_Screen: pop.w ax cs:add.w ax, HexCursor add.w ax, si cs:move.w si, HexSource rts ***************************************************************************** _On_Screen: pop.w bx ; Set the new cursor cs:add.w bx, HexCursor ; Memory pointer. cs:move.b CursorY, al ; See if we are stil and.w #$ff, ax ; on the same X line. add.w bx, ax bpl.s _going_up add.w #!NUM_CHARS*2, ax cs:div.b CharsPerLine cs:sub.b al, CursorX bra.s _set_Y_pos _going_up: cs:div.b CharsPerLine cs:add.b al, CursorX ; Save the new X pos. _set_Y_pos: cs:move.b ah, CursorY ; Save the new Y pos. rts ***************************************************************************** HexDisplay: cs:les TargetData, di cs:lds HexSource, si eor.w ax, ax ; Line number count Hex_Display_lp: push.w ax lea 160(di), di ;Move to the next line. push.w di bsr.w Draw_Line ;Do a line, ooops.. pop.w di pop.w ax inc ax cmp.w #!NUM_LINES, ax blt.s Hex_Display_lp rts ***************************************************************************** Draw_Line: cs:move.b AddrCol, ah ; move.w ds, bx ; move.w #4, cx ; bsr.w Print_Hex ; bsr.w Print_Colon1 ; cs:move.b AddrCol, ah ; move.w si, bx ; move.w #4, cx ; bsr.w Print_Hex ; dc.b $66 ; Extend... eor.w ax, ax ; Clear AX dc.b $66 ; Extend... stos.w #2, di ; Add a space. bsr.w Print_Colon1 ; Print a colon. move.w #0, dx ; draw_lp: cs:cmp.w HexCursor, si bne.s _colour1 move.b #!HIGH_COL, ah bra.s _colour_set _colour1: cs:move.b HexColB, ah test.w #1, si beq.s _colour_set cs:move.b HexColA, ah _colour_set: lods.b bsr.w HPrint_Char move.b al, bl move.b #2, cl bsr.w Print_Hex inc.b dl cmp.b #!NUM_CHARS, dl bne.s draw_lp bsr.w Print_Colon1 ; Print a colon. eor.w ax,ax ; Clear AX. stos.w ; Print a space. rts ***************************************************************************** HPrint_Char: push.w di push.w ax move.w dx, bx rol #1, bx lea !NUM_CHARS*4+4(di), di sub.w bx, di cmp.b #32, al bge.s Hprint_it move.b #'.', al Hprint_it: stos.w pop.w ax pop.w di rts ***************************************************************************** IncSegment: bsr.w GetSourceVar cs:inc.w 2(si) dc.b $80,$FC,$91 bne.s _Inc_End cs:add.w #99, 2(si) _Inc_End: rts ***************************************************************************** DecSegment: bsr.w GetSourceVar cs:dec.w 2(si) dc.b $80,$FC,$8D bne.s _Dec_End cs:sub.w #99, 2(si) _Dec_End: rts ***************************************************************************** Goto: bsr.w GetSourceVar push.w si ;Save SI. move.b #!BC, ah move.w #17, cx move.w #1, bx bsr.w DrawBox push.w di sub.w #160, di move.w #GoPrompt, dx ;The message. bsr.w Print_String ;Print it. pop.w di lea 6(di), di move.b #1, bh ;Set we allow a colon seperator move.w #$404, cx ;Set 4 characters either side of colon. bsr.w Input_Hex ;Get Hex input. pop.w di ;Get our storage address. cmp.w #$11b, ax ;Escape aborts... beq.s _Goto_Exit ;Quit. move.w dx, si ;Pre-load the data eor.w bx, bx ;Clear our work space cmp.b #4, ch ;Check if we have a segment beq.s _Offset_lp ;No segment to go _GetSeg_lp: asl.w #4, bx cs:move.b (si), al or.b al, bl inc.b ch inc.w si cmp.b #4, ch bne.s _GetSeg_lp cs:move.w bx, 2(di) inc.w si ;Set the segment. eor.w bx, bx _Offset_lp: asl.w #4, bx cs:move.b (si), al or.b al, bl inc.b cl inc.w si cmp.b #4, cl bne.s _Offset_lp cmp.w #CodSource, di ;Check which display mode. beq.s _Not_Hex cs:move.w HexCursor, cx ;A nifty trick... cs:sub.w HexSource, cx ;Add the screen to goto address. add.w bx, cx cs:move.w cx, HexCursor _Not_Hex: cs:move.w bx, (di) ;Set the offset. _Goto_Exit: rts ***************************************************************************** Input_Hex: move.w #StackBot, si ;Where to store the input. move.w si, dx ;Save the start address. Input_Hex_lp: bsr.w Get_KeyStroke ;Get some input. or.w ax, ax ;Check for input... beq.s Input_Hex_lp ;None, so loop again. cmp.w #$11b, ax ;Escape pressed? beq.s In_Hex_Out cmp.b #$d, al ;Carriage return? bne.s _Check_Delete ;Yep, so quit... cs:cmp.b #':', -1(si) ;Can't have a colon ending the address beq.s Input_Hex_lp bra.s In_Hex_Out _Check_Delete: cmp.b #8, al ;Delete? bne.s _Check_Colon ;No, continue with checks... cmp.w si, dx ;Anything to delete? beq.s Input_Hex_lp ;Nope! loop again. dec.w si ;Move back one. cs:cmp.b #':', (si) ;Was the last character a colon? bne.s _sub_hexchar xchg.b ch, cl ;Swap the Lft/Rgt counters. inc.b bh bra.s _skip_hexchar ;All done... _sub_hexchar: inc.b cl _skip_hexchar: move.b #!BC, ah eor.b al, al sub.w #2, di es:move.w ax, (di) bra.s Input_Hex_lp _Check_Colon: cmp.b #':', al bne.s _Check_Hex or.b bh, bh beq.s Input_Hex_lp cmp.w si, dx beq.s Input_Hex_lp xchg.b ch, cl dec.b bh move.b al, ah bra.s In_Col_Prnt _Check_Hex: or.b cl, cl beq.s Input_Hex_lp move.b al, ah sub.b #'0', ah bmi.s Input_Hex_lp cmp.b #9, ah ble.s In_Hex_Prnt and.b #$df, al move.b al, ah sub.b #$37, ah cmp.b #$a, ah blt.s Input_Hex_lp cmp.b #$f, ah bgt.s Input_Hex_lp In_Hex_Prnt: dec.b cl In_Col_Prnt: cs:move.b ah, (si) inc.w si cs:move.b #!BH, ah stos.w bra.w Input_Hex_lp In_Hex_Out: or.b bh, bh bpl.s _Skip_Swap xchg.b cl, ch _Skip_Swap: rts ***************************************************************************** GetSourceVar: move.w #CodSource, si dc.b $2E,$81,$3E dc.w PQ1-2, CodDisplay-PQ1 beq.s _Hex_Var move.w #HexSource, si _Hex_Var: rts ***************************************************************************** GoPrompt dc.b " Enter Address ",0 CharsPerLine dc.w !NUM_CHARS *****************************************************************************