English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 01 March 2007, 09:33   #1
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
A little proggie...

I know a couple of skilled or aspiring ASM coder dwell here so I've got a favor to aks . I want to include a simple gauge proggie in Hombre but all the ones I've found so far lack in features or simply refuse to work.

This little utility would:
  • run on 1.3 kick
  • open a small window (or just the titelbar) and displays the following:
  • - free memory
  • - track position of each drive
  • - time, date
  • adjust window's position via cli arguments
  • allow to adjust the display format
  • use as little memory as possible

for example:
gauge -drive 0 -chip -date -time -w=0,0 -f=%cb,%d,%t,%s

would open the window in the top-left corner, display the current track postion in DF0:, available chip memory, date and time like so

910123 bytes | 04-12-80 | 12:14 | 41

So if you wanna make one amiga user very happy...
Please, pretty please
ppill is offline  
Old 18 April 2011, 18:30   #2
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
*Bump*

The next version of Hombre is coming along nicely and something like described above would be great... anyone?
ppill is offline  
Old 19 April 2011, 11:52   #3
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Displaying the track position could be a problem because the hardware itself doesn't tell the exact position, and IIRC access to the trackdisk.device is exclusive, but I could be wrong on that. At least I can't think of any neat method to get the track positions of the drives.

What was wrong with the existing utilities? Do you need some fancy displays or graphics for this? Just putting some text in a thin titlebar-sized window is not a problem.
Leffmann is offline  
Old 19 April 2011, 12:22   #4
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
Quote:
Originally Posted by Leffmann View Post
Displaying the track position could be a problem because the hardware itself doesn't tell the exact position, and IIRC access to the trackdisk.device is exclusive, but I could be wrong on that. At least I can't think of any neat method to get the track positions of the drives.

What was wrong with the existing utilities? Do you need some fancy displays or graphics for this? Just putting some text in a thin titlebar-sized window is not a problem.
Right now I'm using a program called TD (TrackDsiplay) by Preben Nilsen:
http://aminet.net/package/misc/fish/fish-0543

source in assembler included so have a look how he goes about it... (pretty sure not in a very system friendly way)

I don't need anything fancy just what I've described in the first post. The problem right now is that you'd have to use two separate programs for it and none of the ones I found were small enough or didn't let you change the format of the display.

As for now I use zshell's built in MemClock feature (displays free mem and time but disappears after you open a new window together with TD which only displays head positions for each drive).

Any help would be greatly appreciated

http://aminet.net/package/misc/fish/fish-0399

Here's another one by Olaf Barthel (c source included)
ppill is offline  
Old 19 April 2011, 20:50   #5
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Thanks I'll take a look at how they read track positions.
Leffmann is offline  
Old 20 April 2011, 16:09   #6
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Here's a first version, only displaying time, date and amount of free memory for now.

I decided to move the text out of the title bar because changing the title causes flickering on 1.3, and drawing text in the title bar using other methods is error prone. And also because on 1.3 the gadgets use up a bit of space and you quickly fill the screen width when you start adding status items.

Last edited by Leffmann; 12 May 2011 at 23:35.
Leffmann is offline  
Old 21 April 2011, 15:23   #7
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
Quote:
Originally Posted by Leffmann View Post
Here's a first version, only displaying time, date and amount of free memory for now.

I decided to move the text out of the title bar because changing the title causes flickering on 1.3, and drawing text in the title bar using other methods is error prone. And also because on 1.3 the gadgets use up a bit of space and you quickly fill the screen width when you start adding status items.
That's great!!! Thanks a ton Will check it out ASAP.



Works great!

Last edited by TCD; 21 April 2011 at 17:36. Reason: Back to back posts merged. Use the edit function.
ppill is offline  
Old 21 April 2011, 15:57   #8
Zetr0
Ya' like it Retr0?
 
Zetr0's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Age: 49
Posts: 9,768
OOooOOOo

interesting =)
Zetr0 is offline  
Old 21 April 2011, 20:42   #9
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Just a small update, you can now format the status text freely. Will look into the diskdrive status next.

It uses the standard C formatting flags for time, which you can f.ex find here: http://www.cppreference.com/wiki/chrono/c/strftime
and also %C for free chip memory, %F for fast and %T for total.

gauge "Chip %C Fast %F | %X | %A %d-%b-%Y" gives full memory, time and date status f.ex.

Last edited by Leffmann; 12 May 2011 at 23:35.
Leffmann is offline  
Old 21 April 2011, 22:20   #10
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
@Leffmann

Looking good Thanks for taking the time to make it happen. It will be a great addition to the next version of Hombre.



Here it is running with the following options:

Code:
run gauge "Memory: %T bytes free | %H:%M | %d-%m-%Y"


Some further suggestions:

- maybe it could detach itself from the current CLI process (no need to run it)
- an option to open it as a borderless/notitlebar/backdrop window (save an extra line of the text for another window). Of course this would come after the window position option...

really happy with this

Last edited by ppill; 22 April 2011 at 10:37.
ppill is offline  
Old 22 April 2011, 16:40   #11
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Added diskdrive status on %0 through %3. It displays -- when a drive is either not available or has no disk inserted, and updates the status 10 times a second which should be enough. Test it to make sure it behaves like you expect it to. The command line is now gauge x y "formatting", but there are no sanity checks on that input yet.

Quote:
Originally Posted by ppill View Post
Some further suggestions:

- maybe it could detach itself from the current CLI process (no need to run it)
- an option to open it as a borderless/notitlebar/backdrop window (save an extra line of the text for another window). Of course this would come after the window position option...

really happy with this
I'm looking into these things to make it look and behave a bit better.

I agree the proper thing would be to have it detach itself from the CLI, but the AmigaOS APIs are horribly arcane and the code needed to detach from the CLI process is almost a small application in itself. If you already have the run command available in Hombre it would be great for now.

Last edited by Leffmann; 12 May 2011 at 23:35.
Leffmann is offline  
Old 22 April 2011, 16:54   #12
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
Transferring it right now

By sanity checks you mean that the position is not verified before opening the window (so you could end up trying to open a window outside of the display)?

The 'run' bit as you said is a small detail. Nothing to worry about.

Just a small question. Does it lock the CON: window it was started from? Do you have to provide 'run <NIL: >NIL: gauge...' redirections?

I keep repeating myself... thanks!

Just the backdrop/borderless thing and we're set

Or maybe another small thing... free space on a volume/disk like %vdf0 %vSystem

EDIT:
It works! Just like it's supposed to
And just another note... it seems to lock CON: for output... but again nothing to worry about as '>NIL:' will take care of that

Last edited by ppill; 22 April 2011 at 17:04.
ppill is offline  
Old 22 April 2011, 17:07   #13
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Quote:
Originally Posted by ppill View Post
By sanity checks you mean that the position is not verified before opening the window (so you could end up trying to open a window outside of the display)?
Neither that nor the order of the arguments. I've just been adding in all the functionality for now, will polish all the details later.

Quote:
Originally Posted by ppill View Post
Just a small question. Does it lock the CON: window it was started from? Do you have to provide 'run <NIL: >NIL: gauge...' redirections?
The C startup code might, but my own code doesn't touch the standard in and out, and only accepts the command line as sent by the C startup code. I'm not too familiar with this part of the AmigaDOS, what behavior are you looking for?

Quote:
Originally Posted by ppill View Post
Or maybe another small thing... free space on a volume/disk like %vdf0 %vSystem
Ok, I'll look into that too.
Leffmann is offline  
Old 22 April 2011, 17:23   #14
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
Quote:
Neither that nor the order of the arguments. I've just been adding in all the functionality for now, will polish all the details later.
It works... that's the important bit. There's already an alias that configures everything as it should be.

Quote:
The C startup code might, but my own code doesn't touch the standard in and out, and only accepts the command line as sent by the C startup code. I'm not too familiar with this part of the AmigaDOS, what behavior are you looking for?
When you run something it starts a different process so the command prompt is free but when you try to end the parent shell process (endcli for example) the prompt disappears but the window remains because it still expects messages from the command issued (via run) from it. So you end up with a pretty much useless window that will close only when the program quits.

Have a look here:
http://aminet.net/package/util/cli/RunBack

Nothing major really as >NIL: suppresses that window lock.

Quote:
Ok, I'll look into that too.
Great
ppill is offline  
Old 26 April 2011, 16:39   #15
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Added volume sizes on %vvolume: and %Vvolume: which prints free space in bytes and in abbreviated form as 1.2M, 345K, 678 or a dash character if the volume is not available. For the diskdrives it currently only works properly if you have a disk already inserted and leave it there, but looking into fixing this next.

Memory flags changed to %fc %ff %ft to show number of free bytes or %Fc %Ff %Ft to use the abbreviated form.

The abbreviated sizes are rounded down and count in amounts of 1000 and 1000000 bytes (as opposed to 1024 and 1048576).

Quote:
Originally Posted by ppill View Post
When you run something it starts a different process so the command prompt is free but when you try to end the parent shell process (endcli for example) the prompt disappears but the window remains because it still expects messages from the command issued (via run) from it. So you end up with a pretty much useless window that will close only when the program quits.

Nothing major really as >NIL: suppresses that window lock.
Right, that makes sense. I don't see this little app ending up on desktops everywhere so I think it's ok to specialize it for Hombre and just let your scripts handle this detail. It saves me a lot of coding, and this way we're both helping eachother out.

Last edited by Leffmann; 12 May 2011 at 23:35.
Leffmann is offline  
Old 26 April 2011, 23:57   #16
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
Quote:
Added volume sizes on %vvolume: and %Vvolume: which prints free space in bytes and in abbreviated form as 1.2M, 345K, 678 or a dash character if the volume is not available. For the diskdrives it currently only works properly if you have a disk already inserted and leave it there, but looking into fixing this next.

Really cool feature there... the more choice the better. Maybe you could go full monty and add a percentage (free/full) display as well

Quote:
Right, that makes sense. I don't see this little app ending up on desktops everywhere so I think it's ok to specialize it for Hombre and just let your scripts handle this detail. It saves me a lot of coding, and this way we're both helping eachother out.

Believe me, you're doing most of the hard work

The whole detach thing is nothing to worry about. It's not really a case of good vs sloppy coding. Sometimes you want to know what a program returns to its standard output (errors, warnings, info on what the hell it's doing etc.). Dozens of programs have to be started that way, especially patches. It just bloats the executable with unnecessary code. What's the point anyway when you could add redirection or use programs like RunBack or AsyncRun...

As always any updates appreciated
ppill is offline  
Old 29 April 2011, 16:22   #17
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Moved the text into the title bar, and you can also specify -1 as X and/or Y window position to make it pop up at right side and bottom of the screen directly at startup, maybe you can test it and see if it looks and behaves like you expect. Diskdrive volume information still needs fixing.

Last edited by Leffmann; 12 May 2011 at 23:34. Reason: fixed another bug and uploaded new archive
Leffmann is offline  
Old 30 April 2011, 20:25   #18
ppill
CON: artist
 
ppill's Avatar
 
Join Date: Feb 2006
Location: Poland
Age: 43
Posts: 1,250
Will check it tonight (been busy with finishing up the next release of Hombre).

Thanks for sticking with it... keep 'em coming
ppill is offline  
Old 02 May 2011, 09:26   #19
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Leffmann
I agree the proper thing would be to have it detach itself from the CLI, but the AmigaOS APIs are horribly arcane and the code needed to detach from the CLI process is almost a small application in itself.
Detaching your process from the CLI is not too hard, you can use CreateProc() for that. I'll attach an example for you so you can see how it works, it's not much tested but should do the trick. Hope it helps.

Code:
; Create task

START	move.l	$4.w,a6
	lea	DOSname(pc),a1
	moveq	#0,d0
	jsr	-552(a6)		; OpenLibrary()
	lea	DOSbase(pc),a0
	move.l	d0,(a0)
	beq.b	.exit
	move.l	d0,a6

	lea	TaskName(pc),a0
	move.l	a0,d1			; name
	moveq	#0,d2			; priority
	lea	START-4(pc),a1
	move.l	(a1),d3			; seglist
	move.l	d3,Segment-TaskName(a0)
	clr.l	(a1)
	move.l	#4096,d4		; stack size
	jsr	-138(a6)		; CreateProc	
	moveq	#0,d0
	rts

	

.exit	rts

DOSname		dc.b	"dos.library",0
TaskName	dc.b	"TestProc",0
		CNOP	0,4
Segment		dc.l	0
DOSbase		dc.l	0




	SECTION	CODE,CODE
TEST	move.w	#$f00,$dff180
	btst	#6,$bfe001
	bne.b	TEST

	move.l	Segment,d1
	beq.b	.out
	move.l	DOSbase,a6
	jsr	-156(a6)		; UnLoadSeg()

	move.l	a6,a1
	move.l	$4.w,a6
	jsr	-414(a6)		; CloseLibrary()

.out	rts
Attached Files
File Type: s CreateProc.s (750 Bytes, 139 views)

Last edited by StingRay; 02 May 2011 at 14:19. Reason: Corrected quote
StingRay is offline  
Old 03 May 2011, 16:39   #20
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Quote:
Originally Posted by StingRay View Post
Detaching your process from the CLI is not too hard, you can use CreateProc() for that. I'll attach an example for you so you can see how it works, it's not much tested but should do the trick. Hope it helps.
Thanks, I've got code for this now that takes care of the directory lock and picks up the process to unload the C startup code (I'm writing the app in C) in the end as well, though I've already decided to let the Run command handle all of this. Thanks for posting the code though.

What I need to do now is find a way of seeing if a device or volume is available, without having AmigaDOS open the "Insert volume ..."-requester, that can also handle removable media like diskettes and PCMCIA devices properly.
Leffmann is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Someone wrote a KGLoad type proggie.... Bloodwych Amiga scene 22 12 August 2010 00:58
Looking for old comms proggie bigmac request.Apps 2 28 January 2009 14:13

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:50.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14865 seconds with 14 queries