English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 17 May 2015, 12:00   #1
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
gfxbase negative offset

I have problem with finding out where point this offset, mean

Code:
;d0 - point to gfxBase (just after opening graphics.library)
move.l d0,a0
move.l (-$130,a0),a0 ;!!! a0 = ???
move.l (-4,a0),d0      ;!!! d0 = ???
where point this -$130 ? Where I can find any documentation about such negative offsets ? Any ideas ?
Asman is offline  
Old 17 May 2015, 13:15   #2
Codetapper
2 contact me: email only!
 
Codetapper's Avatar
 
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
The standard Amiga libraries all use a table of 6 bytes for all functions, a jmp ($4ef9) followed by the address of the function.

I'd say this code is looking for the _LVORectFill routine (based on lvo/graphics.i):

Code:
GfxBase-$132: jmp _LVORectFill    ;GfxBase-$130 is the _LVORectFill pointer
Then it's reading the longword directly before the routine. Quite possibly only works on some specific kickstart version, as if that longword isn't directly before the routine, then the value in d0 will be completely different. What game is this from?
Codetapper is offline  
Old 17 May 2015, 13:29   #3
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Ahhh.... right. Thank you.

Quote:
Originally Posted by Codetapper View Post
What game is this from?
Not game but util from aminet (2b_RemIBorder) which should remove border from icons. But this util doesn't work on my A600 2mb chip with kick 37.350 wb 38.36. Also I checked other utils like noiconborder (doesn't work too) and NoFillNoDraw (shows guru). So I decide to check what is inside of these utils and I started with 2b_RemIBorder.
Asman is offline  
Old 17 May 2015, 15:12   #4
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,801
@Asman
I'm the author of NoFill/Nodraw, it was the first to remove borders...clone followed.
Back then I only had an A500 with WB 2 so it should work on a plain A600. I didn't wrote it to work with CPU higher than 68000 and seeing all the clones done I didn't pursue the development any further.
I could try to make a WinUAE conf like yours to try if it crash or not.
Kamelito
kamelito is offline  
Old 17 May 2015, 16:35   #5
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by Codetapper View Post
The standard Amiga libraries all use a table of 6 bytes for all functions, a jmp ($4ef9) followed by the address of the function.

I'd say this code is looking for the _LVORectFill routine (based on lvo/graphics.i):

Code:
GfxBase-$132: jmp _LVORectFill    ;GfxBase-$130 is the _LVORectFill pointer
Then it's reading the longword directly before the routine. Quite possibly only works on some specific kickstart version, as if that longword isn't directly before the routine, then the value in d0 will be completely different. What game is this from?
Maybe the code is checking for a bug fixed SetPatch() installed RectFill() with a detection cookie before the code start?
matthey is offline  
Old 17 May 2015, 17:09   #6
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@kamelito
The problem was with following instruction bxx.l which are exists on 68020+. I changed it to bxx.s and now NoDraw works (but of course I click ResetWB to see effect ). Also I see that for example dos.library is closed twice.
So that would be very nice if you can post sources to Your closed projects like this then I see possibility to improve them. If you don't mind I will spend some time on NoDraw util to optimize some things.
Asman is offline  
Old 17 May 2015, 18:09   #7
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,343
Quote:
Originally Posted by matthey View Post
Maybe the code is checking for a bug fixed SetPatch() installed RectFill() with a detection cookie before the code start?
I haven't looked at the code, but its own patch may have a signature cookie longword before the new function code. The program would check for that before trying to install or remove its patch.
mark_k is offline  
Old 17 May 2015, 20:40   #8
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,801
Quote:
Originally Posted by Asman View Post
@kamelito
The problem was with following instruction bxx.l which are exists on 68020+. I changed it to bxx.s and now NoDraw works (but of course I click ResetWB to see effect ). Also I see that for example dos.library is closed twice.
So that would be very nice if you can post sources to Your closed projects like this then I see possibility to improve them. If you don't mind I will spend some time on NoDraw util to optimize some things.
@Asman

I put the binary and source code to the zone for U. IIRC it's the same version available on Aminet.
Didn't check the code so if something is missing ping me.
Regards
Kamelito

PS You're lucky since it was lost and I partially recovered my A3000 HD and the source was there with 2 others software from a friend of mine. One being a resource tracker which try to free resources when a task crash. I also have OCB but this I can't release without authors permission.

Last edited by kamelito; 17 May 2015 at 20:45.
kamelito is offline  
Old 17 May 2015, 20:53   #9
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@kamelito

Thanks a lot for source. And of course I look into code and thing which I don't understand is not commented

Code:
;asman: If I understand correctly prg is new Draw (grahpcis routine -246) start address


prg
	cmp.l	#$00000008,8(a7) ; ??? can someone explain this
	beq	NoDraw
Another obvious question is. What status of source is.
Asman is offline  
Old 17 May 2015, 22:11   #10
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,801
@Asman,
Status : whatever you want just don't forget to put my name where it is due.
As for can someone explain this is... :
This is everything and nothing at the same time. To understand it you need a bit of history.
NoFill/NoDraw was uploaded at aminet because a friend of mine like it and thought some other could. It was sitting in my HD a couple of years before being there.
History : When Amiga OS 2 launched I didn't like at all the icon's borders so I start investigating of way of removing them. I put some hypothesis like it is drawn, so I start patching draws functions until I found which ones were performed while icons where displayed. Then I wrote down the addresses, I used a developer tools to see who owned those addresses spaces and it was the workbench.library. So I start to see if I could directly patch the wb to remove those ugly borders... I was out of luck because the code was in the middle of the wb and wb was in ROM. So I remove my A590 (lend by a friend) and attached an action replay and I traced the code and did some analysis. Knowing I couldn't patch the ROM, I plan to patch the Draw function instead. The problem is that this function is called by a lot of programs and systems functions. Using the Action Replay I tried to find a way to patch only the Draw calls performed for the icon's border.
This is what the "cmp.l #$00000008,8(a7)" is used for, it tell NoDraw that a draw call is used to draw a border around an icon so don't Draw if found. This is all the "magic". This is a bit of a hack but it is quite consistent I think.
This is the story, so If you find a program removing the icon borders like this then it is based on my program. Two of them put a greeting for my work while a well known one didn't...

Kamelito
kamelito is offline  
Old 25 May 2015, 16:11   #11
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Quote:
Originally Posted by mark_k View Post
I haven't looked at the code, but its own patch may have a signature cookie longword before the new function code. The program would check for that before trying to install or remove its patch.
Of course... I'm was so blind. Thank you.

@kamelito

First at all. Thanks a lot for sources, explanation, it helps me a lot.

So there is changed and optimized version of that patch.

Code:
;=============================================================================
;
; Changed and optimized version of NoDraw V1.02 by Kamel Biskri
;
; Thanks and respect going to Kamel Biskri.
;
; Usage: just put in Startup-Sequence after loadwb and before endcli
;        or run it when Workbench is loaded and then click on ResetWB
;        to see changes.
;
; Util works with kick 2+
;
; known bugs: util doesn't work before loadwb was called, because there is
; no workbench task (I think!). If you put util into WBStartup drawer then
; it doesn't work too.
;
; code 216 bytes
; exe  252 bytes
;
; asman
;=============================================================================

	INCDIR	includes:

	IFND	EXEC_EXEC_I
	INCLUDE	"exec/exec.i"
	ENDC
	IFND	LIBRARIES_DOSEXTENS_I
	INCLUDE	"libraries/dosextens.i"
	ENDC

	INCLUDE "lvo/exec.i"
	INCLUDE "lvo/graphics.i"

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

	SECTION	NoDraw,CODE

start:
	;determine type of start: CLI or WB
		move.l	4.w,a6			;get exec base
		move.l	ThisTask(a6),a0		;get our Process structure
		moveq	#0,d0			;WBStartup msg
		tst.l	pr_CLI(a0)		;we start from CLI or WB
		bne.b	.storeMsg

	;from WB. get the startup msg sended by workbench
		lea	pr_MsgPort(a0),a2 
		jsr	_LVOWaitPort(a6)
		lea	pr_MsgPort(a0),a2
		jsr	_LVOGetMsg(a6)		;d0 = WBStartup msg

.storeMsg	move.l	d0,d5			;store it, will be used when
						;we return the startup message
						;at then end of program
	;open graphics library v36 or higher
		lea	gfxName(pc),a1
		moveq	#36,d0
		jsr	_LVOOpenLibrary(a6)
		move.l	d0,d7			;store gfx base
		beq.b	.restoreMsg

	;alloc memory for patch (it will be not released)
		moveq	#PATCH_SIZE,d0
		moveq	#MEMF_PUBLIC,d1
		jsr	_LVOAllocMem(a6)
		move.l	d0,d6			;store patch begin place
		beq.b	.closeGfx

	;find out workbench task
		lea	workbench(pc),a1
		jsr	_LVOFindTask(a6)
		move.l	d6,a2
		move.l	d0,(a2)+		;store wb task
		move.l	a2,d0			;d0 = start adress od patch code

	;copy only patch code to memory
		lea	patchDraw(pc),a0
		moveq	#PATCH_CODE/2-1,d1
.loop		move.w	(a0)+,(a2)+
		dbf	d1,.loop

	;change graphics.library function Draw to relocated patch
		;d0 = start adress of relocated patch
		lea	(_LVODraw).w,a0		;function to patch
		move.l	d7,a1			;gfx base lib pointer
		jsr	_LVOForbid(a6)
		jsr	_LVOSetFunction(a6)
		move.l	d0,(a2)			;save old draw pointer
						;right after patch code
						;will be used in patch
		jsr	_LVOPermit(a6)
.closeGfx
	;close graphics library
		move.l	d7,a1
		jsr	_LVOCloseLibrary(a6)

.restoreMsg
		move.l	d5,d0			;get WBStartup message
		beq.b	.exit
	;prevent before workbench do UnLoadSeg
		jsr	_LVOForbid(a6)
	;return the startup message
		move.l	d0,a1
		jsr	_LVOReplyMsg(a6)
.exit:		moveq	#0,d0
		rts

;-----------------------------------------------------------------------------

patchDraw:
	;magic code to check if border is drawn (respect to Kamel Biskri)
		cmp.l	#8,8(sp)
		bne.b	.draw
		move.l	a0,-(sp)
	;check if is it workbench process
		move.l	4.w,a0
		move.l	ThisTask(a0),a0
		cmp.l	patchDraw-4(pc),a0	;after relocation of patch code
						;this point to wb task address
		move.l	(sp)+,a0		;Condition Code Register is not
						;changed in this case :)
		beq.b	.exit			;so we can now decide to jump
						;if workbench task trying to
						;draw border, otherwise just
						;run old draw function

.draw		move.l	oldDrawPtr(pc),-(sp)	;after relocation of code
						;old draw pointer will be 
						;located right after patch code
.exit		rts

oldDrawPtr:	;mandatory label

;patch size is increased by 8 because 4 bytes take wb task address and 4 bytes
;take old Draw function address
;
PATCH_CODE	equ	*-patchDraw
PATCH_SIZE	equ	PATCH_CODE+8

workbench:	dc.b	'Workbench',0
gfxName:	dc.b	'graphics.library',0
		dc.b	"$VER: IconNoBorder v1.0",0
In the zone source and exe.

Respect.


Edit: If there is a bug or something that can be improved then I'm open for any suggestion.
Asman is offline  
Old 25 May 2015, 21:30   #12
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,801
@Asman
Thanks to continue working on it, it's nice to see it alive in 2015. I'm going to download your updated version and give it a go.

Kudos
Kamelito

PS Don't forget Aminet

Last edited by kamelito; 25 May 2015 at 21:48.
kamelito is offline  
Old 25 May 2015, 21:47   #13
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,518
Quote:
Originally Posted by Asman View Post
lea pr_MsgPort(a0),a2
jsr _LVOWaitPort(a6)
lea pr_MsgPort(a0),a2
A0 will be modified when WaitPort returns (but only if WaitPort had to wait = it probably works accidentally in most normal situations)
Toni Wilen is online now  
Old 26 May 2015, 13:16   #14
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,801
@Asman
"Edit: If there is a bug or something that can be improved then I'm open for any suggestion. "

-Test if the patched fx is not already patched not only by clone, it could crash if one of the program quit and replace the old pointer while the program that it is pointing to is not there anymore. (low probability)
- Test the OS version because IIRC in AmigaOS 3.5 and 3.9 this feature was implemented.
-Detect maybe if Magelan or Scalos is not lauched as WB replacement.
-Add NoFill to this patch, IIRC my solution was not working in some condition ex: with WB background it was kinda transparent.

Kamelito
kamelito is offline  
Old 28 May 2015, 23:24   #15
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@Toni
Thanks a lot, of course there is silly bug, should be
Code:
lea pr_MsgPort(a0),a2
move.l a2,a0
jsr _LVOWaitPort(a6)
move.l a2,a0
jst _LVOGetMsg(a6)
@kamelito
I didn't make any progress (no free time ), but I think that three your points from four should be easy. I don't have knowledge how to detect Scalos or Magelan, because I never used them. Any ideas about it are welcome. And of course thanks for suggestions.

respect
Asman 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
A negative review of Shadow of the Beast Fred the Fop Nostalgia & memories 76 13 June 2015 23:45
IGN being negative towards Amiga Djay Retrogaming General Discussion 39 08 November 2011 20:26
Program Counter with Offset - why? Jherek Carnelia Coders. General 26 21 March 2011 10:49
WHDLoad - NTSC and screen offset Anubis project.WHDLoad 4 27 January 2010 21:20
GfxRip Palette and Offset questions stef80 project.Sprites 2 06 July 2007 19:59

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 18:51.

Top

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