English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 28 June 2024, 07:36   #1
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
Assign floppy’s to different directories WHDLOAD Slave

Hello. I gave a question of assignment for floppys with different names and to call from different subdirectories each one. I have this code:

HTML Code:
_bootdos	lea	(_saveregs,pc),a0
		movem.l	d1-d3/d5-d7/a1-a2/a4-a6,(a0)
		move.l	(a7)+,(11*4,a0)
		move.l	(_resload,pc),a2	;A2 = resload

	;open doslib
		lea	(_dosname,pc),a1
		move.l	(4),a6
		jsr	(_LVOOldOpenLibrary,a6)
		lea	(_dosbase,pc),a0
		move.l	d0,(a0)
		move.l	d0,a6			;A6 = dosbase

	;assigns
		lea	_disk1(pc),a0
		sub.l	a1,a1
		bsr	_dos_assign
		lea	_disk2(pc),a0
		sub.l	a1,a1
		bsr	_dos_assign
And the assignments:

HTML Code:
_disk1		dc.b	"intro",0		;for Assign
_disk2		dc.b	"game",0		;for Assign
_program	dc.b	"mainrun",0
_args		dc.b	"",10	;must be LF terminated
_args_end
What it makes is when the floppy names called ‘intro’ and ‘game’ are required by the exe ‘mainrun’ it will call the files in the current directory. I don’t have assigned a subdirectory. However, how can I make to assign that when the program calls the floppy ‘intro’ instead to call its files from current directory it calls the files from the subdirectory ‘dir1’ and when files from floppy ‘game’ are called they are loaded from subdirectory ‘dir2’. I don’t want to share the same directory for both floppys. What is needed to add to the code to make this?
field3d is offline  
Old 28 June 2024, 07:43   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
load a1 with subdir string
jotd is offline  
Old 28 June 2024, 17:21   #3
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
Quote:
Originally Posted by jotd View Post
load a1 with subdir string
Ok. Thx @JOTD I will try
field3d is offline  
Old 28 June 2024, 19:23   #4
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
I tested @JOTD. However, I made this test:

HTML Code:
		;assigns
		lea	_disk1(pc),a0
		lea _dir1(pc),a1  
		;sub.l	a1,a1
		bsr	_dos_assign 

		lea	_disk2(pc),a0
		lea _dir2(pc),a1		
		;sub.l	a1,a1
		bsr	_dos_assign
		
	;assigns
	;	lea	(_disk1,pc),a0
	;	sub.l	a1,a1
	;	bsr	_dos_assign
	
	
		lea	_df0(pc),a0
		sub.l	a1,a1
		bsr	_dos_assign	

;;;;;Exe1		
	;load exe1
		lea	_program1(pc),a0
		move.l	a0,d1
		jsr	(_LVOLoadSeg,a6)
		move.l	d0,d7			;D7 = segment
		beq	.program_err			;file not found

		;run exe2
		move.l	d7,a1
		add.l	a1,a1
		add.l	a1,a1
		lea	(_args,pc),a0
		move.l	(4,a7),d0		;stacksize
		sub.l	#5*4,d0			;required for MANX stack check
		movem.l	d0/d7/a2/a6,-(a7)
		moveq	#_args_end-_args,d0
		
		jsr	(4,a1)
	
		movem.l	(a7)+,d1/d7/a2/a6
	
		;remove exe2
		move.l	d7,d1
		jsr	(_LVOUnLoadSeg,a6)
;;;;;Exe1	

_disk1		dc.b	"LOG",0		;for Assign
_disk2		dc.b	"SIM",0		;for Assign
_dir1		dc.b	"1_LOG",0		;for Assign
_dir2		dc.b	"2_SIM",0		;for Assign
_program1	dc.b	"MAIN",0
_args		dc.b	"",10	;must be LF terminated
_df0:
	dc.b	"DF0",0
*Where _disk1 is the name of the floppy AmigaOS requests and that in amiga you would call as “cd LOG:”. It’s a floppy drive name. _disk2 is the other floppy AmigaOS name you would call in a regular cli as “cd SIM:”. In both cases you access the floppy’s in such way.

*_dir1 and _dir2 are the directories inside the default directory of the SLAVE and that directories are where whdload must go and search the files. For example if AmigaOS when you run MAIN exe it requires the Floppy called ‘LOG’ it will go to _dir1 to grab files from there, in other words the dir ‘1_LOG’, the same for _dir2 if the floppy ‘SIM’ is needed to be inserted by AmigaOS it must call to grab files inside the directory _dir2 in other words the directory ‘2_SIM’.

*The routine ‘;load exe1’ I use to load and execute the program called MAIN that is located in the default directory of the slave.

*When I run the slave it runs fine and runs the program but at some point exactly when you will be asked for the floppy _disk2, the ‘SIM’ floppy name or at some point around there crash with the error:

HTML Code:
Exception "Illegal Instruction" ($10)
at $FFDE694 (Task 'Initial CLI', Prg 'ROM trackdisk 34.1 (18 Aug 1987)' Off $1130, ExpMem occurred.
What would be the problem here? I don’t know if the assignments of the floppy names I made correctly or this is another problem.

Last edited by field3d; 29 June 2024 at 03:57.
field3d is offline  
Old Yesterday, 00:26   #5
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
Assembly Code Part of the Crash

I want to add that I detected debugging the assembly code the part that crash. Apparently is a routine involving load or making assignments of the floppy. The part that comes in the program is the insert disk called ‘SIM’ and in the normal floppies this part is wait for the floppy ‘SIM’ to be inserted to continue if you insert done. In the slave and the code I made making the assignment to A1 of that “SIM’ to the directory ‘2_SIM’ that part of the program crash, even never reaches the insert ‘SIM’ message or anything it goes straight to the crash.

Now the code of the program in that part of the crash is:

HTML Code:
$0002102C MOVEM.L D0-07/A0-A6,-(A7)
$00021030 MOVE.L (4), A6
$00021036 SUBA.L A1, A1
$00021038 JSR?-$126,A6)
$0002103C MOVE.L D0,($2112C) 
$00021042 LEA ($2112C),A1
$00021048 JSR (-$162),A6
$0002104C LEA ($210CC),A1
$00021052 MOVE.L #$2111C,($E,A1)
$0002105A MOVE.L ($2113C),D0
$00021060 CLR.L D1
$00021062 LEA ($210BA),A0
$00021068 JSR (-$1BC,A6)
$0002106C TST.L D0
$0002106E BNE.W $210AE
$00021072 LEA ($210CC),A1
$00021078 MOVE.W ($21140),($1C,A1)
$00021080 MOVE.L ($21142),($2C,A1)
$00021088 JSR (-$1C8,A6) ***********************
$0002108C MOVE.L ($20,A1),($21146)
$00021094 LEA ($2111C),A1
$0002109A JSR (-$168,A6)
$0002109E LEA ($210CC),A1
$000210A4 JST (-$1C2,A6)
$000210A8 MOVEM.L (A7)+,D0-D7/A0-A6
$000210AC RTS
The ‘***********************’ is the line where it crash with the error ‘Exception "Illegal Instruction" ($10)
at $FFDE694 (Task 'Initial CLI', Prg 'ROM trackdisk 34.1 (18 Aug 1987)' Off $1130, ExpMem occurred.’

This segment code of the program are the vestiges of a routine for assignment, load file or read tracks or sectors?

What could cause the crash in that line? Of course I understand is not possible know with exact precision but an idea or tip. In previous lines of the crash line ‘***********************’ what could be happening or what can be missing in the task?
field3d is offline  
Old Yesterday, 01:07   #6
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
JSR (-$1C8,A6) is exec.DoIo. Not related to assign.

but the error is at $FFDE694 not 21088. If it happens when you call there, it means that the program crashed the ROM, which is not good.
jotd is offline  
Old Yesterday, 04:20   #7
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
Quote:
Originally Posted by jotd View Post
JSR (-$1C8,A6) is exec.DoIo. Not related to assign.

but the error is at $FFDE694 not 21088. If it happens when you call there, it means that the program crashed the ROM, which is not good.
Thank you @JOTD for the clarification. Oh I see. Something in the loading of whdload is deteriorating that part. Well I will check what it is as I suppose may be any number of different issues that causes this. It’s just a simply executable of 6 KB who regulates this.

Well, I made test now instead of booting files I used the feature ‘DISKSONBOOT’ and booting from there runs perfect no errors. However, in the program never reaches the part in the same way that says insert the disk ‘SIM’ because is interrupted by this message: “REMOVE Write_Protection and Restart !”. Meaning that is considering the image made by DIC as disk write protected and of course maybe it tries to write and it can’t. In this cases, is there way similar than the assign but to write in a specific directory what it attempts to write and make believe the program the Disk.1 is writable? Or create a clean Disk.3 for this purpose and how is changed to write and make believe the Disk.3 is where needs to write?

Or simply can I make believe the Disk.1 is writable and that in fact writes there?Or what is the accustomed here?

I’m checking the both paths to see what is the best to do here if the bootdos or the disksonboot.
field3d is offline  
Old Yesterday, 08:01   #8
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
Working Now!

I made it working now regarding the crash. The crash I could fix with the next routine. No more crash:

HTML Code:
_disk1  	dc.b    "LOG",0  
_disk2  	dc.b    "SIM",0 
_dir1		dc.b	"1_LOG",0		;for Assign
_dir2		dc.b	"2_SIM",0		;for Assign  

slv_CurrentDir	dc.b	"data",0
_program	dc.b	"MAIN",0
_args		dc.b	10
_args_end	dc.b	0
_dosbase	dc.l	0
		EVEN

;============================================================================


_bootdos

		move.l	_resload(pc),a2		;a2 = resload

		lea	_dosname(pc),a1		;Open doslib
		move.l	(4),a6
		jsr	_LVOOldOpenLibrary(a6)
		lea	(_dosbase,pc),a0
		move.l	d0,a6			;A6 = dosbase
		
		;enable cache
		move.l	a0,-(A7)
		move.l	#WCPUF_Base_NC|WCPUF_Exp_CB|WCPUF_Slave_CB|WCPUF_IC|WCPUF_DC|WCPUF_BC|WCPUF_SS|WCPUF_SB,d0
		move.l	#WCPUF_All,d1
		jsr	(resload_SetCPU,a2)
		
		lea	_disk1(pc),a0		;Assigns
		lea _dir1(pc),a1 
		;;sub.l	a1,a1
		bsr	_dos_assign
		
		lea	_disk2(pc),a0		;Assigns
		lea _dir2(pc),a1 
		;;sub.l	a1,a1
		bsr	_dos_assign

		lea	_program(pc),a0
		lea	_args(pc),a1
		moveq	#_args_end-_args,d0
		
		movem.l	d0-a6,-(a7)
		move.l	d0,d2
		move.l	a0,a3
		move.l	a1,a4
		move.l	a0,d1
		jsr	(_LVOLoadSeg,a6)
		move.l	d0,d7			;D7 = segment
		beq	.end			;file not found

		;call
		move.l	d7,a1
		add.l	a1,a1
		add.l	a1,a1
		IFD CHIP_ONLY
		move.l  (a1),a0
		add.l   a0,a0
		add.l   a0,a0
		move.l  a0,$100.W   ; segment #1 (not 0)
		ENDC
    
		move.l	a4,a0
		move.l	($44,a7),d0		;stacksize
		sub.l	#5*4,d0			;required for MANX stack check
		movem.l	d0/d7/a2/a6,-(a7)
		move.l	d2,d0			; argument string length
		jsr	(4,a1)
		movem.l	(a7)+,d1/d7/a2/a6

		;remove exe
		move.l	d7,d1
		jsr	(_LVOUnLoadSeg,a6)

		movem.l	(a7)+,d0-a6
		rts
I added that cache routine and this order and works apparently as there is no more error of memory. But the problem is as is not recognizing the ‘SIM’ assignment to the directory maybe because I made the next test:

Originally I have:

HTML Code:
_disk2  	dc.b    "SIM",0 
_dir1		dc.b	"1_LOG",0		;for Assign
_dir2		dc.b	"2_SIM",0		;for Assign
And there is no error message but stays as searching but does nothing.

The test I made is to see if at least the assignment _disk2 it works. I change to:

HTML Code:
_disk2  	dc.b    "!!!!!!SIM",0 
_dir1		dc.b	"1_LOG",0		;for Assign
_dir2		dc.b	"2_SIM",0		;for Assign
Now making that is asking me the name of the Floppy SIM and that is correct because there is no argument of _disk2 called ‘SIM’ but I return to
HTML Code:
‘ _disk2  	dc.b    "SIM",0“
I doesn’t ask the floppy but does nothing.

Is supposed it needs to go to the directory ‘2_SIM’ I have there the whole floppy but I have correct my assignment of that dir in the code or what could be happening? Now the crash is not happening but I have this issue.
field3d is offline  
Old Yesterday, 08:08   #9
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
Also if I make this test asks the floppy:

HTML Code:
_disk2  	dc.b    "SIM",0 
_dir1		dc.b	"1_LOG",0		;for Assign
_dir2		dc.b	"!!!!!2_SIM",0		;for Assign
Then is supposed it should working as bot _disk2 and _dir2 are triggering a result if I touch them.
field3d is offline  
Old Yesterday, 09:59   #10
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,319
Without seeing what "do_assign" does, it is hard to judge. The dos.library function "AssignAdd()" does what you want, or better still, the "assign" command.
You do not need to enable caches, that is what SetPatch does for you.
Finally, I suggest not starting programs just with a jsr as this will not provide command line arguments to them properly. ReadArgs() will not be able to pick them up with this method - might be ok if it is your own program. I suggest "RunCommand()".

Anyhow, if the attempt is just to load and execute a binary, "System()" does the job, or a custom startup-sequence.
Thomas Richter is offline  
Old Yesterday, 20:31   #11
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,223
Quote:
Originally Posted by Thomas Richter View Post
Without seeing what "do_assign" does, it is hard to judge. The dos.library function "AssignAdd()" does what you want, or better still, the "assign" command.
You do not need to enable caches, that is what SetPatch does for you.
Finally, I suggest not starting programs just with a jsr as this will not provide command line arguments to them properly. ReadArgs() will not be able to pick them up with this method - might be ok if it is your own program. I suggest "RunCommand()".

Anyhow, if the attempt is just to load and execute a binary, "System()" does the job, or a custom startup-sequence.
This is good advice if you're targeting 2.0+ for general cases, but for whdload it's not really applicable. The WHDload builtin assign is no worse and also works for 1.3 (which is the target for 95%+ of whdload slaves). The complicated start stuff is not necessarily needed, but you're usually just looking for a good place to do your patching, and might make it easier (if the programs needs ReadArgs you will/should know as the patcher).


@OP: Only really general advice can be given. You will have to disasm/debug on your own. Generally I'd say don't mess with cache settings unless you're disabling them (which is usually a good start), and use the SNOOP option (with MMU) to check if any the programs are accessing hardware directly rather than going through DOS.
paraj is offline  
Old Yesterday, 22:32   #12
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,379
The "DISKSONBOOT" flag is probably a good option if game uses trackdisk. Ex: archon trackdisk

Code:
NUMDRIVES	= 1
WPDRIVES	= %1111

DISKSONBOOT
BOOTBLOCK
There are some flags you can set to enable/disable write protection. But sometimes games used a mix OS/hardware approach (reading BFD100 for disk protect happens sometimes).

I suggest you use IRA + cheapres or AiraForce to perform a proper disassembly of the exe, see what it does at crucial points. Without disassembly, you can get lucky, or get stuck... Also there's the issue of detecting the proper disk / swap disks at the proper location. Reversing the game and patching it to switch disks before game checks them is often required, because most trackloading OS compliant games with more than 1 disk only use DF0:
jotd is offline  
Old Yesterday, 22:35   #13
field3d
Registered User
 
Join Date: Feb 2019
Location: USA/Texas
Posts: 58
@jotd @paraj @Thomas. Thank you for the tips. Finally I could make it work. Yes it was a check in a place with an intro we had from time ago and also I made a sequential load of 3 files in the same whdload so all the sequence is preserved as in the past. Now I will try to explore to make an Installer. But I tested now and it works very good. Yes @paraj is needed to disassemble deep some times, is something really frustrating some times but as in this case there is no other solution.
field3d 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
Multiple ASSIGN's to merge directories under one drive Stardust support.AmigaOS 7 28 July 2022 22:53
Changing directories Biquet support.FS-UAE 3 02 May 2020 14:49
How to assign two separate game directories amigappc project.ClassicWB 2 24 December 2015 14:49
EasyADF Sub Directories chocolate_boy support.Apps 0 18 June 2014 16:21
Faster floppy file dialog for large directories? rsn8887 request.UAE Wishlist 7 23 January 2012 06:31

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 00:36.

Top

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