4 ----------------------------------------------  EDIT - Disk editor 4 ---------------------------------------------- ( 2# param 12, sectab 39, data 255 <osword=&FFF1 F 7 Pbegin : get drive Z : repeat d main : main loop n" 7 : normal cursor x' get%=&8F : until user finished    begin  23;11,0;0;0;0; $ set KEY 0 to &8C, KEY 1 to &8D $ set KEY 2 to &8E, KEY 3 to &8F *KEY0 |!|L *KEY1 |!|M *KEY2 |!|N *KEY3 |!|O  display header head  get drive number   3,5);38," ") "& 3,5);130;"Enter drive (0-3)"; , " > "drive% 6 drive%>-1 drive%<4 @" *DRIVE for this drive number J "DRIVE "+drive% T get user to insert disk ^.3,7);130;"insert disk in drive ";drive% h.3,8);130;"press SPACE when ready to go" r (100)=32 | find out how many tracks  A%=&7E  X%=param Y%=X% 256  osword maxtrack%=(!param 2560)-1    choices  disable cursor editing  *FX4,1  display choices $0,21);133;"you may edit the"; *131;"hex";133;"or the";129;"ASCII" 90,22);131;"(f0 = other half : f1 = main menu )" 90,23);131;"(f2 = update disk : f3 = quit program)"  & 0 : D coord N get cursor coordinates Xx%= by%= l v dispdata  display header  head & display a 16 by 8 matrix of data  I%=1 16  displine(I%) I%  display choices  choices ! position cursor at 1st byte  31,5,4   displine(W%)   display a line of data ! set J%=relative byte number  J%=part%*128 + 8*(W%-1) */ set start% to address of 1st byte of data 4start%=data+J% >) set str$ to 2-byte hex string of J% Hstring(J%) R5 print it in green and set up the rest in yellow \" 0,W%+3);130;str$;131;" "; f, initialise ASCII representaion of data p A$="" z! for each of 8 bytes of data  Z%=0 7  set C% = next byte  C%=start%?Z% ( store ASCII representation in A$ . C%<32 C%>126:A$=A$+"." A$=A$+(C%) * set str$ = 2-byte hex string of C%  string(C%)  print it  str$;" ";  ' print ACSII representation in red  129;A$    down  move cursor down one line $ 10 . get cursor coordinates 8 coord B7 if it's fallen off the bottom, wrap around to top L y%>19 31,x%,4 V ` j edit t get cursor coordinates ~ coord $ if user editing ASCII do edit2  x%>29:edit2: = user is editing hex, so change key-in from ASCII to hex get%=get%-&30  get%>9:get%=get%-7 # make sure the key-in is valid  get%<0 :  get%>15: < calculate relative memory address of byte being edited *mem%=part%*128 + 8*(y%-4) + (x%-5) 3 ( find existing value of left nibble left%=data?mem% 16 ) find existing value of right nibble  right%=data?mem% 16 ; if user is editing left nibble, overwrite left nibble ! else overwrite right nibble (+ (x%-5) 3=0:left%=get% right%=get% 2" put new value back in memory <data?mem%=16*left%+right% F redisplay whole line Pdispline(y%-3) Z restore cursor position d 31,x%,y% n move cursor right x right    edit2 / get relative address of byte being edited %mem%=part%*128 + 8*(y%-4) + x%-30 + overwrite this byte with key-in value data?mem%=get%  redisplay whole line displine(y%-3)  restore cursor position  31,x%,y%  move cursor right  right    err "% handle a bad result from OSWORD , head 60,5);129;bad$ @#0,6);129;"result = &";~res% J+0,8);133;"press SPACE for main menu" T (100)=32 ^ h r get | get keyboard input   get%= > if user pressed f0, toggle next half of sector display * get%=&8C:part%=part% 1:dispdata + if user pressed f2, update the disk  get%=&8E:write " if cursor key, move cursor  get%=&88:left  get%=&89:right  get%=&8A:down  get%=&8B:up " if editing a byte, do edit ! get%>&1F get%<&80:edit + repeat all this until user wants to 1 return to main menu, updater disk or quit  get%>&8C & 0 : head D display screen header N X#10,0);141;132;"DISK EDITOR" b#10,1);141;132;"DISK EDITOR" l v  left  move cursor left  8  get cursor corrdinates  coord > if it's falled off at the left, wrap around to the right  x%<5 : 31,37,y%: . if it's at X=28 or X=29, move it to X=30  x%>29:  x%=28: 8:  x%=29: 8,8: $ if it's in a gap, move it left  (x%-4) 3=0: 8     main   23;11,0;0;0;0; * main menu program loop 4 find out which track > menu H( seek track 0, reset track register R seek(0) \' read sector IDs from wanted track fsectorids p% if any problems, return to main z res%<>0:  find out which sector  whichsec  set track register track(?sectab)  read the sector  read % if any problems, return to main  res%<>0: 3 initialise display to 1st 128 bytes of sector  part%=0  special editing cursor  23;10,0;0;0;0;  23;11,255;0;0;0;  display 128 bytes of data  dispdata ! start reading from keyboard $get . 8 B menu L find out which track V@%=2 ` head j t 0,5);38," ") ~; 0,5);130;"Enter track number (0 - ";maxtrack%;")";  " > "track% $ track%>-1 track%37: 31,5,y%: " x%>29: ,! don't leave cursor in a gap 6 x%=28: 9,9: @ x%=29: 9: J (x%-4) 3=0: 9 T ^ hsectorids r read sector IDs |param?0=drive% : drive param!1=sectab : address *param?5=3 : num of parameters (param?6=&5B : read sector IDs 'param?7=track% : physical track param?8=0 : dummy 'param?9=10 : num of sectors ow(10)  report any problems  res%=0: 1bad$="track "+(track%)+" missing sector IDs" err   seek(T%)  seek a track param?0=drive% : drive &#param!1=&FFFF : no address 0*param?5=1 : num of parameters :param?6=&69 : seek D'param?7=T% : physical track N ow(8) X report any problems b res%=0: l%bad$="tack "+(track%)+" missing" verr   string(num%) ( make 2-byte hex string of a number str$="0"+~num%,2)      track(T%)  adjust track register param?0=drive% : drive #param!1=&FFFF : no address *param?5=2 : num of parameters 'param?6=&7A : write spec reg ! pick correct track register *& drive% 2=1:reg%=&1A reg%=&12 4param?7=reg% : reg >param?8=T% : value H ow(9) R \ fup p move cursor up one line z 11  get cursor coordinates coord < if cursor falls off the top, wrap around to the bottom  y%<4: 31,x%,19   whichsec found out lowest sector ID lowsec%=sectab?2  I%=1 9 ; sectab?((4*I%)+2) "sector% t, sector%>lowsec%-1 sector%0:code%=&4F code%=&4B param?6=code% : write param?7=?sectab : track param?8=sector% : sector #param?9=&21 : one sector  ow(10)  *res%=res% &1E : mask off delete bit  report any problems  res%=0: (*bad$="sector "+(sector%)+" bad write" 2err <