English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 01 February 2014, 16:34   #1
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
some dodgy source code

I wonder if any of you know what is wrong with this source code that I typed up from the book Amiga Assembler Insider Guide by Paul Overaa? It is meant to display a graphic but displays a corrupt window then crashes. Maybe has something to do with the LVO offsets? Just I had to rename the two include files to .s to get them to upload to here. If anyone has the disk for this book that would be great also.
Attached Files
File Type: s Example_CH15-2.s (4.8 KB, 140 views)
File Type: s Defines2.s (871 Bytes, 121 views)
File Type: s Macros2.s (2.2 KB, 127 views)
Steve is offline  
Old 01 February 2014, 20:04   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
Attach also compiled binary, it is much easier to debug if both binary and source is available than to guess if the problem is in source code, your assembler or somewhere else.
Toni Wilen is offline  
Old 01 February 2014, 20:43   #3
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Ah I didn't realise that. Ok I have also attached the binary.

The thing is there is an additional file for the example in the book called 'function_offsets.i' but the code isn't given.
I assumed these were just the _LVO library offsets so added them to Defines.i
I did think it was strange adding the offsets manually. I thought they were already defined in the commodore includes?
Attached Files
File Type: zip window_draw.zip (869 Bytes, 105 views)
Steve is offline  
Old 01 February 2014, 21:12   #4
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Slightly updated binary with proper window size values. I hadn't entered the correct values from the book. Still gives a program failure message though after it closes itself and the graphics don't look like much. Just a few small horizontal lines?? And on a Picasso uaegfx display which I code on it looks like an screwy corrupt mess inside the window with lines all over the place?
Attached Files
File Type: zip draw_window2.zip (871 Bytes, 115 views)
Steve is offline  
Old 01 February 2014, 22:17   #5
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
Quote:
Originally Posted by Steve View Post
Still gives a program failure message though after it closes itself and the graphics don't look like much.
Two things spring to mind:

1) Is d0 cleared (set to 0) before exiting the program? Anything other than a value of 0 indicates to workbench that an error has occured

2) Are you properly handshaking with workbench at start and exit? You need to store the specific message (ID?) that workbench allocates to your program at startup and reply to it when exiting. Failing to do so generates an error message.



Edit: Just looked at your source code (Example_CH15-2.s) and you did clear d0 before exiting so ignore my first idea (above), but you do not do any handshaking as mentioned in my 2nd idea (above).

FYI: replace clr.l d0 with moveq #0,d0 (the latter is 2 cycles faster and does exactly the same thing)

Last edited by Lonewolf10; 01 February 2014 at 22:35.
Lonewolf10 is offline  
Old 01 February 2014, 23:00   #6
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Quote:
Originally Posted by Lonewolf10 View Post
Edit: Just looked at your source code (Example_CH15-2.s) and you did clear d0 before exiting so ignore my first idea (above), but you do not do any handshaking as mentioned in my 2nd idea (above).

FYI: replace clr.l d0 with moveq #0,d0 (the latter is 2 cycles faster and does exactly the same thing)
Hi. Thanks I didn't know that. About the handshaking, is it easy to add to the program? As it's an introductory book it leaves out a lot of information on the finer details of Workbench coding.
Steve is offline  
Old 02 February 2014, 00:31   #7
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,861
Reading the code I think that it has been written to be launched from the shell and not the workbench. Is it crashing if you launch it from the shell?
As for the corrupted image, I'm not sure but the datas are mostly zeroes. Images datas should be in chip memory though. Did you try on OCS?

Kamelito

Last edited by kamelito; 02 February 2014 at 00:54.
kamelito is offline  
Old 02 February 2014, 09:06   #8
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Hi. Thanks for your reply. It uses the intuition library so is meant to be run from workbench. I have written other programs from the book that are DOS only. I think it is supposed to display diagonal lines in the window because as you say there are mostly zeros in the image data.
Steve is offline  
Old 02 February 2014, 09:40   #9
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,861
It's not because it uses Intuition that it must be launched from WB.
Kamelito
kamelito is offline  
Old 02 February 2014, 10:21   #10
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
Intuition (and nearly everything else) can be used without WB.

Example programs are rarely WB compatible (unless they are C programs and linker adds WB packet support automatically or they are meant to show how to do WB programs ). Always run them from CLI/Shell.

0x07000004 guru (AsyncPkt) is the most common side-effect for trying to run non-WB compatible program from WB by clicking its icon. (WB packet is put in same queue that dos uses and dos does not want to see it)
Toni Wilen is offline  
Old 02 February 2014, 11:19   #11
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,861
IMHO the planpick and planoff should be "dc.b $00,$03,$00,$00" since it's bytes here not words.
Don't know if the assembler permit or correct such things.
Kamelito


Image1:
dc.w 0,0 X,Y origin relative to container TopLeft
dc.w 395,215 Image width and height in pixels
dc.w 2 Number of bitplanes in image
dc.l ImageData1 Pointer to ImageData
dc.b $0003,$0000 PlanePick and PlaneOnOff
dc.l NULL Next image structure
kamelito is offline  
Old 02 February 2014, 11:22   #12
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Ah ok. I tried in DOS and it doesn't crash anymore when the program closes. The graphics still look a bit odd as you can see. Maybe you are right kamelito about changing the PlanePick and PlaneOnOff definitions to byte values?
Attached Thumbnails
Click image for larger version

Name:	Assembler Test_001.png
Views:	240
Size:	23.1 KB
ID:	38877  
Steve is offline  
Old 02 February 2014, 11:30   #13
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Ok, this is interesting. I changed the dc.b to dc.w I get this result. A large blue rectangle?? Do you think this is correct? More importantly it actually works in Workbench now without crashing!
Attached Thumbnails
Click image for larger version

Name:	Assembler Test_002.png
Views:	216
Size:	18.1 KB
ID:	38878  
Steve is offline  
Old 02 February 2014, 12:25   #14
kamelito
Zone Friend
 
kamelito's Avatar
 
Join Date: May 2006
Location: France
Posts: 1,861
Can't say as I don't own that book. I doubt it can run from the WB without crashing thought (except if you did manage WB signal stuff)
Kamel
kamelito is offline  
Old 02 February 2014, 12:31   #15
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
I can't explain it but now the program doesn't crash from WB even if I change the code back. Very strange. The dc.b values must be correct and not an error as I checked the Image structure definition and those values are marked as UBYTE and the rest are WORD so they should be dc.b. As for the blue rectangle this is obviously not what the image is supposed to look like. It is either a diagonal white line or horizontal white line? I'm not if the ImageData is incorrect. It could be a misprint in the book although it listed twice and is the same both times. It would really be handy to have the disk with this book.
Steve is offline  
Old 02 February 2014, 12:59   #16
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,351
PlanePick and PlaneOnOff are byte fields, so don't change those to dc.w. You might want to remove the leading pair of zeros from each but that's just cosmetic.

Looking at your source code:
Code:
Image1:		dc.w	0,0				X,Y origin relative to container TopLeft
		dc.w	395,215				Image width and height in pixels
		dc.w	2				Number of bitplanes in image
		dc.l	ImageData1			Pointer to ImageData
		dc.b	$0003,$0000			PlanePick and PlaneOnOff
		dc.l	NULL				Next image structure
		SECTION Image,DATA_C

ImageData1:	dc.w $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
		dc.w $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
...
The amount of image data is far less than needed for a 395×215 2-plane image. Are you sure you didn't mis-type the width and height in the Image structure? Or did you just not post all of the image data here?
mark_k is offline  
Old 02 February 2014, 13:53   #17
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
It is exactly as it is in the book. Must be an error in the book.
Steve is offline  
Old 02 February 2014, 21:27   #18
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Yes it seems like the full code for the image wasn't printed. I copied some ImageData code from a similar program on the Mastering Amiga Assembler disk, added it to my code and it compiled fine and looks correct. Also the crashing still seemed to occur when I tested it. Looks like as far as the corrupt image is concerned that one is solved. Maybe they didn't print the entire listing because it took up too many pages? Who knows.
Attached Thumbnails
Click image for larger version

Name:	Workbench 3_001.png
Views:	234
Size:	21.4 KB
ID:	38889  
Steve is offline  
Old 02 February 2014, 21:47   #19
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,351
Does the program still crash when you run it from a CLI/Shell window, not Workbench?
mark_k is offline  
Old 02 February 2014, 21:55   #20
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
Quote:
Originally Posted by mark_k View Post
Does the program still crash when you run it from a CLI/Shell window, not Workbench?
No. Strange thing is it works fine on my main development Workbench using uaegfx at 1024x768 24 bit but on a standard Workbench screen it gives the software failed message in the corner. It's a bit odd but oh well. It only crashes though once the program has run its course.
Steve 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
My old source code gemanix Coders. General 36 09 July 2017 13:33
DoomAttack source code MickJT support.Games 10 15 October 2013 13:03
Source Code camelord support.Games 2 06 August 2010 17:45
the citadel source code hippie2000 Coders. General 8 29 October 2007 15:10
Source Code Thalion project.WinUAE - Kaillera 3 28 April 2006 09:55

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 10:25.

Top

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