English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 22 June 2011, 02:05   #21
Galahad/FLT
Going nowhere

Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 45
Posts: 7,008
Quote:
Originally Posted by StingRay View Post
This can't be the cause of the crash.
Well aware of that, but clearly he needs to give his code more scrutiny, if not the moveq, then code in and around that area, as I assume he gets the system back at least which would suggest his code on exit is to blame.
Galahad/FLT is offline  
Old 22 June 2011, 03:39   #22
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
If anyone has or suspects problems with Devpac/GenAm, there is vasm which is very compatible in Devpac compatibility mode and is actively developed...

http://sun.hasenbraten.de/vasm/
matthey is offline  
Old 22 June 2011, 05:28   #23
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,186
Quote:
Originally Posted by Lonewolf10 View Post
I'm pretty sure my code is good and that something Devpac 3.18 is doing is causing this. Does anyone have any pointers?
The are a couple of issues with your startup code, but just like you say it's not your startup code that causes the guru. It gurus because you're not responding to the message that Workbench is sending you.

A program started from the CLI doesn't need to do anything to run properly, but a program started from the Workbench must retrieve a startup message sent by the Workbench before doing anything else, and return this message to the Workbench before quitting.

I can give you my code if you'd like, or you can find instructions on how to do this in the RKM Libraries manual.


Quote:
Originally Posted by matthey View Post
If anyone has or suspects problems with Devpac/GenAm, there is vasm which is very compatible in Devpac compatibility mode and is actively developed...
High five for vasm!

Last edited by Leffmann; 22 June 2011 at 05:35.
Leffmann is offline  
Old 22 June 2011, 10:36   #24
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
Quote:
Originally Posted by Lonewolf10 View Post
Which question? I thought I answered everyones questions/comment.
My question why you are so sure that your good is good and that your problem is caused by Devpac.
Reason I asked that question is simply the fact that it's easy to blame something on the tools you use but in most cases it's your code which is buggy. Trust me on that one.


Quote:
Originally Posted by Lonewolf10 View Post
I avoid using libraries as much as possible as they are complicated and I am a newbie when it comes to using libraries, but having reliable system kill/restore libraries is required so that folks can return to workbench afterwards. Personally I'd rather just force them to reset their Amiga's instead.
When it comes to demo coding, you don't need to use many libraries. But those that you use should be used correctly, always check if a library was opened correctly, don't assume anything. Also, rule of thumb, when you have disabled the system (i.e. killed interrupts/DMA) avoid using any system libraries as they expect the system to be intact.

Quote:
Originally Posted by Lonewolf10 View Post
The error started happening around the time I started using Devpac 3.18 (Jan 2011?) and I (wrongly?) assumed they were related.
Check which code you have changed since then and remove the new routines one by one and see when the error disappears.



Quote:
Originally Posted by Lonewolf10 View Post
I am a little sleepy right now, but I'll take a closer look at it tomorrow.
You want to clear the color registers, but, are you really doing that? Check register a0.
StingRay is offline  
Old 22 June 2011, 11:26   #25
Hewitson
Registered User
Hewitson's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 36
Posts: 2,618
Quote:
Originally Posted by Lonewolf10
Personally I'd rather just force them to reset their Amiga's instead.
Hewitson is offline  
Old 23 June 2011, 20:13   #26
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Quote:
Originally Posted by StingRay View Post
Code:
    lea.l    COLOR00,a0
    moveq    #31-1,d0        ;number of colours
kill_system_colours:
    move.w    #0,a0
    addq    #4,a0
    dbra    d0,kill_system_colours
    rts
When I see this I am pretty sure it's not the assembler which causes your problems. Please check what the code is doing and what you want it to do.

Quite right, I overlooked a couple of stupid things there - namely the size of each colour register (2 bytes not 4) and used direct addressing instead of indirect addressing.


Quote:
Originally Posted by StingRay View Post
My question why you are so sure that your good is good and that your problem is caused by Devpac.
Reason I asked that question is simply the fact that it's easy to blame something on the tools you use but in most cases it's your code which is buggy. Trust me on that one.
You have already proven that I write buggy code occasionally

Quote:
Originally Posted by Leffmann View Post
A program started from the CLI doesn't need to do anything to run properly, but a program started from the Workbench must retrieve a startup message sent by the Workbench before doing anything else, and return this message to the Workbench before quitting.
Ok, I didn't know that. Does that also apply to something started at boot-up?


Quote:
Originally Posted by Leffmann View Post
I can give you my code if you'd like, or you can find instructions on how to do this in the RKM Libraries manual.
Thanks for your kind offer, but I have found the instructions in the RKRM: Libraries manual and will try to write my own code for now.


Regards,
Lonewolf10

Last edited by Lonewolf10; 23 June 2011 at 20:16. Reason: typographical error
Lonewolf10 is offline  
Old 23 June 2011, 23:03   #27
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,186
Quote:
Originally Posted by Lonewolf10 View Post
Ok, I didn't know that. Does that also apply to something started at boot-up?
Do you mean in the bootblock or the startup-sequence? Anything run from the startup-sequence is run just like from the CLI.

There are no methods to start program files from the bootblock, so any code you load yourself from the diskdrive can just be run as is. If you want your bootblock to enter AmigaDOS then there's a small procedure that needs to be followed, and it also needs to comply with the AmigaOS ABI and preserve registers D2-D7 and A2-A6.
Leffmann is offline  
Old 23 June 2011, 23:19   #28
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Quote:
Originally Posted by Leffmann View Post
Do you mean in the bootblock or the startup-sequence?
I currently load my demo via the startup-sequence, but it can also be loaded via workbench.

Any future projects will (hopefully) be loaded via the bootblock.


Thanks for answering for both ways anyway


Regards,
Lonewolf10
Lonewolf10 is offline  
Old 24 June 2011, 00:58   #29
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
Quote:
Originally Posted by Lonewolf10 View Post
*bump!*

So hows the demo going hoffman?


Edit:

Back on topic, my demo works fine (in workbench atleast), but when it exits I get an error:

Program failed (error 87000004)


I'm pretty sure my code is good and that something Devpac 3.18 is doing is causing this. Does anyone have any pointers?


Regards,
Lonewolf10
You lot are hijackin my thread!!

To answer Lonewolf, the coding was going very well. So far i've managed to do

scroller
scroller cookie cut over a background
protracker note scrolling display
bitplane sine wave shifting
protracker / theplayer scope (orignally ripped from an old PT source but well an truly my own code now!)
a module deconstruction and rebuild system

I think my proudest effect so far is what I call the banksy effect. spray paints over the screen, which then peels away to reveal a logo, much like stencil art.

Also I put together an entire 3 disk long play music disk using most of the stuff listed above, however, it still has a nasty bug involving the CIA replay and the loader... I'm sure Stingray could fill you in on the fun thats been!!

BTW - that original block of code in this thread?? absolute bag of shite! Thankfully I got a good system startup block from Stingray.

Next on the Agenda....

Finish music disk

Start proper demo!
h0ffman is offline  
Old 24 June 2011, 09:43   #30
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
Originally Posted by h0ffman
Next on the Agenda....

Finish music disk

Start proper demo!
\o/
pmc is offline  
Old 25 June 2011, 23:37   #31
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
I have re-written my kill system and restore system routines (see below), but now whilst my demo works as soon as it tries to return to workbench all I get is a black screen
I also tried saving register values on start-up and restoring on exit, but as soon as I started my demo I got an error (80000004) so I have commented them out for now.

What am I missing, or doing wrong?


New additions are in bold

Code:
;Library offsets taken from Amiga Machine Language, pages 240-243

ExecBase	equ	4

;Exec.Library calls
*******************
CloseLib	equ	-414
FindPort	equ	-390
FindTask	equ	-294
Forbid		equ	-132
GetMsg		equ	-372
OldOpenLib	equ	-408
Permit		equ	-138
ReplyMsg	equ	-378
WaitPort	equ	-384


;Graphics.Library calls
***********************
DisownBlitter	equ	-462
OwnBlitter	equ	-456
LoadView	equ	-222
WaitBlit	equ	-228
WaitTOF		equ	-270


;Intuition.Library calls
************************
RemakeDisplay	equ	-384


kill_system:				;**** Kill System (cleanly?) ****

*	movem.l	d0-d7/a0-a6,-(sp)	;store current register values
	move.l	ExecBase,a6
	jsr	Forbid(a6)		;multitasking off

***					;new, 24th june 2011

	lea.l	demo_name,a1
	jsr	FindPort(a6)		
	cmp	#0,d0
	beq.s	killsys_error
	move.l	d0,msg_port		;save msg port address

	lea.l	msg_port,a0
	jsr	WaitPort(a6)
	lea.l	msg_port,a0
	jsr	GetMsg(a6)	
	move.l	d0,system_msg

***
	lea.l	graphics_lib,a1		;open Graphics.Library
	moveq	#0,d0
	jsr	OldOpenLib(a6)		;returns library address in d0
*****
	cmp	#0,d0
	beq.s	killsys_error		;new <<<--- 24 june 2011
*****
	move.l	d0,graphics_base	;store address
	move.l	d0,a6			;graphics.lib base -> a6
*	beq.s	allsquare_exit
	jsr	OwnBlitter(a6)		;no input/output for both calls
	jsr	WaitBlit(a6)
	move.l	#0,a1
	jsr	LoadView(a6)		;no output
	jsr	WaitTOF(a6)		;no input/output (call twice?)
	jsr	WaitTOF(a6)

	move.w	INTENAR,old_INTENAR	;store current settings
	move.w	INTREQR,old_INTREQR
	move.w	DMACONR,old_DMACONR

	move.w	#$7FFF,INTENA		;disable everything
	move.w	#$7FFF,INTREQ
	move.w	#$07FF,DMACON

	or.b	#%10000000,$BFD100	;as interrupts are off, we manually
	and.b	#%10000111,$BFD100	;switch off disk drive motor

	lea.l	COLOR00,a0
	moveq	#31-1,d0		;number of colours
kill_system_colours:
	move.w	#0,(a0)			;was a0
	addq	#2,a0
	dbra	d0,kill_system_colours
	rts

demo_name:
	dc.b	"DD_AllSquare",0
	even

taskCB:
	dc.l	0

msg_port:
	dc.l	0

system_msg:
	dc.l	0

graphics_lib:
	dc.b	"graphics.library",0
	even

graphics_base:
	dc.l	0

intuition_lib:
	dc.b	"intuition.library",0
	even

intuition_base:
	dc.l	0

old_INTENAR:
	dc.w	0

old_INTREQR:
	dc.w	0
	
old_DMACONR:
	dc.w	0


restore_system:
	move.w	#$7FFF,INTENA		;*** disable everything ***
	move.w	#$7FFF,INTREQ
	move.w	#$07FF,DMACON

	lea.l	intuition_lib,a1	;*** Open Intuition.Library ***
	move.l	ExecBase,a6
	moveq	#0,d0
	jsr	OldOpenLib(a6)		;returns library address in d0
	move.l	d0,intuition_base	;store address
	move.l	d0,a6			;intuition.lib base -> a6
	jsr	RemakeDisplay(a6)

	move.l	ExecBase,a6
	move.l	156(a6),a6
	move.l	38(a6),COP1LCH		;restore workbench copperlist
	move.w	#0,COPJMP1		;write any value to COPJMP1

	move.w	old_INTENAR,d0		;*** restore system settings ***
	bset	#15,d0
	move.w	d0,INTENA
	move.w	old_INTREQR,d0
	bset	#15,d0
	move.w	d0,INTREQR
	move.w	old_DMACONR,d0
	bset	#15,d0
	move.w	d0,DMACON

	move.l	graphics_base,a6
	jsr	WaitTOF(a6)
	jsr	DisownBlitter(a6)

	move.l	ExecBase,a6

***				;new, 24th june 2011

	move.l	system_msg,a1
	jsr	ReplyMsg(a6)
***

	jsr	Permit(a6)
*	movem.l	(sp)+,d0-d7/a0-a6	;restore original register values
	rts

Regards,
Lonewolf10
Lonewolf10 is offline  
Old 26 June 2011, 00:37   #32
hitchhikr
Registered User

 
Join Date: Jun 2008
Location: somewhere
Posts: 376
Code:
;Library offsets taken from Amiga Machine Language, pages 240-243

DMACONR		equ	$dff002
INTENAR		equ	$dff01c
COP1LCH		equ	$dff080
COPJMP1		equ	$dff088
DMACON		equ	$dff096
INTENA		equ	$dff09a
COLOR00		equ	$dff180

ExecBase	equ	4

;Exec.Library calls
*******************
CloseLib	equ	-414
FindPort	equ	-390
FindTask	equ	-294
Forbid		equ	-132
GetMsg		equ	-372
OldOpenLib	equ	-408
Permit		equ	-138
ReplyMsg	equ	-378
WaitPort	equ	-384


;Graphics.Library calls
***********************
DisownBlitter	equ	-462
OwnBlitter	equ	-456
LoadView	equ	-222
WaitBlit	equ	-228
WaitTOF		equ	-270


;Intuition.Library calls
************************
RemakeDisplay	equ	-384


kill_system:				;**** Kill System (cleanly?) ****

*	movem.l	d0-d7/a0-a6,-(sp)	;store current register values
	move.l	ExecBase,a6
	jsr	Forbid(a6)		;multitasking off

***					;new, 24th june 2011

	lea.l	demo_name,a1
	jsr	FindPort(a6)		
	move.l	d0,msg_port		;save msg port address
	beq.b	no_msg

	lea.l	msg_port,a0
	jsr	WaitPort(a6)
	lea.l	msg_port,a0
	jsr	GetMsg(a6)	
	move.l	d0,system_msg
no_msg:
***
	lea.l	graphics_lib,a1		;open Graphics.Library
	moveq	#0,d0
	jsr	OldOpenLib(a6)		;returns library address in d0
*****
	move.l	d0,graphics_base	;store address
	beq.w	killsys_error		;new <<<--- 24 june 2011
*****
	move.l	d0,a6			;graphics.lib base -> a6
*	beq.s	allsquare_exit
	jsr	OwnBlitter(a6)		;no input/output for both calls
	jsr	WaitBlit(a6)
	move.l	#0,a1
	jsr	LoadView(a6)		;no output
	jsr	WaitTOF(a6)		;no input/output (call twice?)
	jsr	WaitTOF(a6)

	move.w	INTENAR,old_INTENAR	;store current settings
	move.w	DMACONR,old_DMACONR

	move.w	#$7FFF,INTENA		;disable everything
	move.w	#$07FF,DMACON

	or.b	#%10000000,$BFD100	;as interrupts are off, we manually
	and.b	#%10000111,$BFD100	;switch off disk drive motor

	lea.l	COLOR00,a0
	moveq	#32-1,d0		;number of colours
kill_system_colours:
	move.w	#0,(a0)			;was a0
	addq	#2,a0
	dbra	d0,kill_system_colours

loop:	btst	#6,$bfe001		;left mouse button
	bne.b	loop
	bra.w	restore_system

demo_name:
	dc.b	"DD_AllSquare",0
	even

taskCB:
	dc.l	0

msg_port:
	dc.l	0

system_msg:
	dc.l	0

graphics_lib:
	dc.b	"graphics.library",0
	even

graphics_base:
	dc.l	0

intuition_lib:
	dc.b	"intuition.library",0
	even

intuition_base:
	dc.l	0

old_INTENAR:
	dc.w	0

old_DMACONR:
	dc.w	0

restore_system:
	move.w	#$7FFF,INTENA		;*** disable everything ***
	move.w	#$07FF,DMACON

	lea.l	intuition_lib,a1	;*** Open Intuition.Library ***
	move.l	ExecBase,a6
	moveq	#0,d0
	jsr	OldOpenLib(a6)		;returns library address in d0
	move.l	d0,intuition_base	;store address
	move.l	d0,a6			;intuition.lib base -> a6
	jsr	RemakeDisplay(a6)

	move.l	ExecBase,a6
	move.l	156(a6),a6
	move.l	38(a6),COP1LCH		;restore workbench copperlist
	move.w	#0,COPJMP1		;write any value to COPJMP1

	move.w	old_INTENAR,d0		;*** restore system settings ***
	or.w	#$c000,d0
	move.w	d0,INTENA
	move.w	old_DMACONR,d0
	bset	#15,d0
	move.w	d0,DMACON

	move.l	graphics_base,a6
	jsr	WaitTOF(a6)
	jsr	DisownBlitter(a6)

killsys_error:

	move.l	ExecBase,a6

***				;new, 24th june 2011

	move.l	system_msg,d0
	beq.b	no_replymsg
	move.l	d0,a1
	jsr	ReplyMsg(a6)
no_replymsg:
***

	jsr	Permit(a6)
*	movem.l	(sp)+,d0-d7/a0-a6	;restore original register values
	moveq	#0,d0			;return code
	rts
hitchhikr is offline  
Old 26 June 2011, 02:58   #33
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Thanks for trying to help, hitchhikr, but I already have those registers defined - I just forgot to list them in the above code.


Regards,
Lonewolf10
Lonewolf10 is offline  
Old 26 June 2011, 03:11   #34
hitchhikr
Registered User

 
Join Date: Jun 2008
Location: somewhere
Posts: 376
Check the code i modified more carefully.
hitchhikr is offline  
Old 26 June 2011, 17:11   #35
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,186
That code will still not work. You have to call FindTask(0) and then find the message port structure at offset pr_MsgPort. You also need to have multitasking disabled before you call ReplyMsg and leave it disabled, or your program memory might get freed up and reused before you've quit. AmigaOS will enable the multitasking again after your program has quit.

The way you find the system's Copper program through the exec base is probably not safe either. You can f.ex enable interrupts first before calling RethinkDisplay or RemakeDisplay and then enable DMA, and the system will write the Copper pointer itself.

Here's a minimal WBStartup you can use like this:

jsr WBStartup
(run demo)
moveq #0, d0
rts
Attached Files
File Type: s WBStartup.s (2.0 KB, 68 views)
Leffmann is offline  
Old 27 June 2011, 11:06   #36
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,201
As Leffmann already assumed, this is causing your black screen by starting a bad copper list.
Code:
        move.l     ExecBase,a6
        move.l     156(a6),a6
        move.l     38(a6),COP1LCH        ;restore workbench copperlist
        move.w     #0,COPJMP1        ;write any value to COPJMP1
156(a6) is ExecBase.IntVects[6]. But you need the GfxBase to restore the copper list from offset 38.
phx is offline  
Old 27 June 2011, 13:07   #37
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
Quote:
Originally Posted by phx View Post
As Leffmann already assumed, this is causing your black screen by starting a bad copper list.
Code:
        move.l     ExecBase,a6
        move.l     156(a6),a6
        move.l     38(a6),COP1LCH        ;restore workbench copperlist
        move.w     #0,COPJMP1        ;write any value to COPJMP1
156(a6) is ExecBase.IntVects[6]. But you need the GfxBase to restore the copper list from offset 38.

You're wrong. This is an old trick to get gfxbase, check my code here for example. I only use this trick when the code needs to be extremely size optimised. It isn't causing the black screen.

I don't know why he uses code like that though (probably copy/pasted from somewhere) when he opens the graphics.lib in a "clean" way in his init code.

As for the black screen, didn't test the code but I see that he still uses RemakeDisplay when the sytem is disabled. That might be one of the reason for the problems.

Last edited by StingRay; 27 June 2011 at 13:15. Reason: Typos
StingRay is offline  
Old 27 June 2011, 13:17   #38
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,201
Quote:
Originally Posted by StingRay View Post
You're wrong. This is an old trick to get gfxbase, check my code here for example.
Oh, indeed, you're right! This works because IntVects[6] is used for the Blitter interrupts, and graphics.library always installs its base in the iv_Data field to get it passed. Might be safe enough, on classic Amigas. Nice trick.
phx is offline  
Old 28 June 2011, 00:00   #39
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 39
Posts: 1,919
Quote:
Originally Posted by hitchhikr View Post
Check the code i modified more carefully.
I did and Leffmann was right, it didn't fix my problem.


Quote:
Originally Posted by phx View Post
As Leffmann already assumed, this is causing your black screen by starting a bad copper list.
Code:
        move.l     ExecBase,a6
        move.l     156(a6),a6
        move.l     38(a6),COP1LCH        ;restore workbench copperlist
        move.w     #0,COPJMP1        ;write any value to COPJMP1
156(a6) is ExecBase.IntVects[6]. But you need the GfxBase to restore the copper list from offset 38.

Err.. no. Everything was working perfectly ok, including returning to workbench, until I tried to fix the problem with the error message I recieved from workbench and ended up making things worse!


Quote:
Originally Posted by Leffmann View Post
Here's a minimal WBStartup...
Many thanks, it's all working as desired and no error messages when returning back to workbench


Quote:
Originally Posted by h0ffman View Post
I think my proudest effect so far is what I call the banksy effect. spray paints over the screen, which then peels away to reveal a logo, much like stencil art.
Sounds very cool


Regards,
Lonewolf10

Last edited by Lonewolf10; 28 June 2011 at 00:12. Reason: forgot to reply to hoffman's message
Lonewolf10 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
Compiling WinUAE 2.1.0 rotacak support.WinUAE 8 06 May 2010 18:09
Help compiling winuaesrc1530 AAG support.WinUAE 2 08 January 2009 12:45
Compiling BlizKick Toni Wilen Coders. General 2 26 December 2007 18:06
Compiling 1.3.4 rotacak support.WinUAE 70 22 January 2007 09:13
Slowly compiling stainy Nostalgia & memories 4 10 September 2002 02:28

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 16:04.


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