; this is extremely messy, please don't try to learn from this. ;; Thanks to Philip Montgomery to his HexView. ;; This is my first program for ZShell! ;; To move use arrows. And: ;; * and / : move by 0x001C bytes(one Page) ;; F1 and F2: move by 0x0100 bytes ;; F4 and F5: move by 0x1000 bytes ;; To edit a location, use Enter and then type the value in hex. ;; You can use + and - to increment or decrement the location byte. ;; ;; Sami Khawam (a9501901@unet.univie.ac.at or sKhawam@bigfoot.com) ;; ported by Greg Milewski ([l0rdg0at@juno.com] || [milewskg@stuy.edu]) ;; Modified by Eric Piel on July 98 #include "crash82.inc" ;key defs, saves time for porting from ti85 ;#include "keys85.inc" ; end key defs, begin vars & title .db "HexEditor v1.3 port Greg M.", 0 EditY = TEXT_MEM ;APD_BUF EditX = EditY+1 ;CurPtr = EditX+1 EditPtr = EditX+1 ;;last + 2 ; end of vars, begin program Start: ; ld a, $8C ;rom page 4 ; out (2), a res 1, (IY+$0D) ; Don't alter text memory with writes res 2, (IY+$0D) call CR_GRBCopy ;fast clearlcd ld hl,0 ld (CURSOR_ROW),hl ld hl,Titel1 ROM_CALL(D_ZT_STR) ld hl, (CurPtr) ld (EditPtr), hl ld hl,$0400 ld (EditY),hl TitelLoop: call CR_KHAND call CR_GRBCopy ;fast clear screen CALL DrawScreen ProgLoop: call GET_KEY cp G_MODE ret z cp G_ENTER JP Z, EditVal cp G_MINUS jr z, DecVal cp G_PLUS jr z, IncVal cp G_WINDOW Jr Z, JumpDown cp G_YEDIT Jr Z, JumpUp cp G_DIV Jr Z, PageUp cp G_TIMES Jr Z, PageDown cp G_GRAPH Jr Z, bigjumpdn cp G_TRACE Jr Z, bigjumpup ;/-used from Jimmy Mardell's Ztetris -\ dec a jr z,DrawDown dec a jr z,DrawLeft dec a jr z,DrawRight dec a jr z,DrawUp ;end of Mardell routine jr ProgLoop DoAdv1: push hl ld de, (CurPtr) add hl, de ld (CurPtr), hl pop hl DoAdv2: ld de, (EditPtr) add hl, de ld (EditPtr), hl DoDraw: CALL DrawScreen jr ProgLoop PageDown: ld hl, 001Ch jr DoAdv1 PageUp: ld hl, -001Ch jr DoAdv1 JumpDown: ld h, 01h ;ld hl, 0100h ;hl=8000h jr DoAdv1 JumpUp: ld hl, - 0100h jr DoAdv1 bigjumpdn: ld h, 10h Jr DoAdv1 bigjumpup: ld hl, - 1000h Jr DoAdv1 IncVal: ld hl, (EditPtr) inc (hl) jr DoDraw DecVal: ld hl, (EditPtr) dec (hl) jr DoDraw DrawLeft: ld a, (EditX) cp 4 WillProgLoop: jr z,ProgLoop sub 2 ld hl, -1 jr LeftOrRight DrawRight: ld a, (EditX) cp 10 jr z,WillProgLoop add a, 2 ld hl, 1 LeftOrRight: ld (EditX), a jr DoAdv2 DrawDown: ld hl, 4 ld a, (EditY) cp 7 jr z, DoAdv1 inc a jr UpOrDown DrawUp: ld hl, -4 ld a, (EditY) or a jr z, DoAdv1 dec a UpOrDown: ld (EditY), a jr DoAdv2 EditVal: ld hl, (EditY) ld (CURSOR_POS), hl set 3, (IY+$05) ld a, '_' ROM_CALL(TX_CHARPUT) ROM_CALL(TX_CHARPUT) ld a, (EditX) ld (CURSOR_COL), a call GetVal push af add a , a add a , a add a , a add a , a ld b, a pop af call HexNum2Letter call GetVal or b ld hl, (EditPtr) ld (hl), a res 3, (IY+$05) jp DoDraw GetVal: push bc ConvertLoop: call GET_KEY ld b,l ;hl=8000h ld hl,LetterConvertTable - 18 ;Point to one before cp 17 ;or a jr c,ConvertLoop ;jr z,ConvertLoop cp 48 jr nc,ConvertLoop ld c,a ConversionLoop: add hl,bc ;inc hl ld a,(hl) or a jr z,ConvertLoop ;Invalid key dec a pop bc ret ;Value is in acc ;;;;;;;;DrawScreen function DrawScreen: ld hl,0 ld (CURSOR_POS), hl ld hl,(CurPtr) ld b, 8 NextRow: push bc ; CALL DisplayLine ;;;;;Function DisplayLine DisplayLine: ; hl -> start of dump ;;;if i want the addr inverted... set 3, (IY+$05) ld a, h CALL PrintHex ld a, l CALL PrintHex ; Print address being decoded res 3, (IY+$05) push hl ld b, 4 ; Do 4 bytes NextChar: ld a, (hl) CALL PrintHex inc hl djnz NextChar pop hl ld b, 4 ; Do 4 bytes NextChar0: ld a, (hl) cp $D6 ;if a=carraige return/line feed, replace w/ ":" jr nz, NextChar1 ld a, $3A ;":" NextChar1: ROM_CALL(TX_CHARPUT) inc hl djnz NextChar0 ; ret ;;;end display line pop bc djnz NextRow ld hl, (EditY) ld (CURSOR_POS), hl set 3, (IY+$05) ld hl, (EditPtr) ld a, (hl) CALL PrintHex res 3, (IY+$05) ret ;;end DrawScreen ;;;;;;;;;;;PrintHex function PrintHex: ; de destroyed push bc push de ld b, a and $0f0 rrca rrca rrca rrca call HexNum2Letter ld a, b and $0f call HexNum2Letter pop de pop bc ret ;;;;;;;;;end PrintHex function HexNum2Letter: add a, 30h cp $3a jr c, IsFigure add a, $7 IsFigure: ROM_CALL(TX_CHARPUT) ret ;0123456789ABCDEF Titel1: .db "HexEdit - Sami K" Titel2: .db $7F," port: Greg M ",$7F .db " ",6,"&",7," & *&/ " .db "Y=,WIN,TRCE,GRAF" .db " Enter to edit " .db "+/- inc. / dec.",0 LetterConvertTable: ;For converting keys into letters ;updated ti82 table ; .db 0,0,0,0,0,0,0,0,0 ;9 ; .db 0,0,0,0,0 ;5 ; .db 0,0,0 ;3 .db 4,7,$0A,0 ;4 .db 0,0,0 ;3 .db 0,3,6,9,0,$10 ;6 .db $0D,0 ;2 .db 1,2,5,8,0,$0F ;6 .db $0C,0,0,0 ;4 .db 0,0,0,$0E ;4 = 46 .db $0B ;,0,0,0,0,0,0,0,0,0 CurPtr: .dw 0 .END