; SHOWMEM.Z80 memory: call banner call gxymsg defb 3,32 defb highon,' Memory Display ',highoff,0 ; Label the columns ld a,(dumpstrt) ; Get starting address low byte and 0fh ; Isolate low hex digit ld c,a ; Keep it in C ld b,16 ; Values to display push bc ; We will need this for the ASCII side call gxymsg defb 5,7 defb highon,' ',0 hdrloop1: ld a,b ; Extra space every four columns and 3 ld a,' ' ; Extra space call z,cout ld a,c and 0fh call pa2hc ld a,' ' call cout inc c ; Increment address djnz hdrloop1 call vprint defb highoff,'|',highon,' ',0 pop bc ; Get address and count back hdrloop2: ld a,c ; Get the address digit and 0fh add a,'0' ; Shift to character representation cp '9'+1 ; If less than 10 jr c,hdrloop3 ; ..branch add a,'A'-'0'-10 ; Shift to proper character representation hdrloop3: call cout inc c djnz hdrloop2 call vprint defb ' ',highoff,0 ld hl,(dumpstrt) ; Starting address to display ld c,16 ; Count for lines mem1: call crlf call phl4hc ; Print address call vprint defb ' --',0 call dumpline ; Display line of memory dec c ; Count down rows jr nz,mem1 prompt: call gxymsg ; Print prompt defb 23,1 defb highon defb ' Command ( <=down, >=up, A=addr, P=poke, CR=menu)? ' defb highoff,' ',0 call ereol ; Clear any junk on line call capine ; Get user input cp 'P' ; Poke? jr z,mempoke cp 'A' ; Address? jr z,memadr cp '>' ; Advance address? jr z,memnextr cp '.' ; Advance address? jr z,memnextr cp '+' ; Advance address? memnextr: jp z,memnext cp '<' ; Backup address? jr z,membackr cp ',' ; Backup address? jr z,membackr cp '-' ; Backup address? membackr: jp z,memback jp getcmd1 ; Otherwise process as main menu command ;---------------------------------------- mempoke: call print defb 'oke addr (hex)? ',0 call getnum jr nc,promptr ; Abort if no number entered ld d,h ; Save a copy of address in DE ld e,l ld bc,(dumpstrt) ; Make sure address is on displayed page xor a ; Make sure carry is clear sbc hl,bc jr c,badval ; Bad if address is before displayed page ld a,h ; High byte of difference must be zero or a jr nz,badval push de ; Save address call at ; Reposition cursor defb 23,52 call ereol ; Clear address prompt call print defb ' Value (hex)? ',0 call getnum pop de ; Address back in DE jr nc,promptr ; Abort if no number entered ld a,h ; Make sure it is a valid byte value or a jr nz,badval ; Branch if bad ld a,l ld (de),a jr memoryr ; Redraw the display badval: ld a,bell ; Beep bell call cout promptr: jp prompt ;---------------------------------------- memadr: call print defb 'ddress (Hex)? ',0 call getnum jr nc,promptr ; Abort if no number entered ld (dumpstrt),hl ; Set new start address memoryr: jp memory ; Back for further commands getnum: ld a,0ffh ; Capitalize call bbline ; Get line from user call sksp ; Skip leading spaces ld a,(hl) ; Check for a character or a ret z ; If no input given, return NC call eval16 ; Evaluate as hex ex de,hl ; Result in HL scf ; If valid, return C ret memnext: ld hl,(dumpstrt) ; Advance one page inc h ld (dumpstrt),hl jr memoryr memback: ld hl,(dumpstrt) ; Decrement one page dec h ld (dumpstrt),hl jr memoryr ; End SHOWMEM.Z80