English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 26 April 2018, 22:16   #1
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
WinUAE gives "HALT3" when blitting a shape to screen

Not being an artist, I want to generate some shapes for a game programatically. Drawing them each time on a bitmap then displaying seems to work fine but slowly, so I thought I'd draw to a temporary BitMap, then GetAShape and blit that.

I thought I'd start off simple and draw a red circle on a standard double-buffered display.

Whenever I get to the bit about blitting my shape, WinUAE dies with HALT3. Which I think is memory related?

However I don't see what I'm doing wrong. Is it me?

Using WinUAE ver 3.6.1 64bit with standard A1200 config.

Code:
;; Play nicely with WB
WBStartup

;; Everything is a WORD unless otherwise stated
DEFTYPE .w

;; Set up a palette with 4 colours, black red green blue
InitPalette 0,4
PalRGB 0,0,0,0,0
PalRGB 0,1,15,00,00
PalRGB 0,2,00,15,00
PalRGB 0,3,00,00,15

;; Set up a CopList, low-res, 2 bitplane
InitCopList 0,$002

;; Temporary bitmap for creating shapes
#BM_DRAW = 9
BitMap #BM_DRAW,320,256,2
Use BitMap #BM_DRAW

;; Draw a 10x10 circle centred on 5,5
Circle 5, 5, 5, 5, 1

;; Get a shape
#SH_1 = 1
GetaShape #SH_1,0,0,10,10 

;; GO BLITZ MODE
BLITZ

;; Not entirely sure what these do but needed to control the screen
CreateDisplay 0
DisplayPalette 0,0

;; Let's start doing double buffering
dp = 0

;; Allocate the two bitmaps
#BM_DISP1 = 0
#BM_DISP2 = 1
BitMap #BM_DISP1,320,256,2
BitMap #BM_DISP2,320,256,2

;; Start off with DISP1
dp = #BM_DISP1

;; Do until mouse press
While Joyb(0)=0
	;; Select a BitMap to use
	Use BitMap dp
	
	;; Wipe out everything
	Cls 0
	
	;; Blit
	Blit #SH_1, 0, 0, 0
	
	;; Display it
	VWait
    DisplayBitMap 0,dp
	
	;; Swap over the display BitMap
	dp = 1 - dp	
	
Wend

End
E-Penguin is offline  
Old 27 April 2018, 09:21   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,507
Halt 3 = CPU instruction opcode fetch from non-existing address. Most common cause is stack return address corruption, too small stack?
Toni Wilen is online now  
Old 27 April 2018, 09:55   #3
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
Ah, good idea. I'll try again with a larger stack and report back.
E-Penguin is offline  
Old 27 April 2018, 10:04   #4
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,335
Are you running the debugger with it? That would normally catch memory issues, though I can't really see what's causing the problem. The fourth parameter of the Blit command isn't normally needed unless you have mismatched depths, and everything you have is 2 bitplanes deep so perhaps using it in that way is triggering some sort of weird bug in the command.

Also, try it without the Cls command - I have an uneasy feeling about commands like that and Floodfill doing weird things to memory...
Daedalus is offline  
Old 27 April 2018, 11:20   #5
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
It did the same thing without the fourth Blit parameter.

If I don't Cls, how ought I blank the BitMap inbetween frames? My concept was to just redraw everything with Blits every time as it's going to be a simple game. Maybe I'm better off doing QBlits?
E-Penguin is offline  
Old 27 April 2018, 11:34   #6
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,335
Yep, maybe QBlit might be the way to go. I meant to disable it just as a test though, to see if it was related to the issue. Another theory (and it's just that, I haven't investigated it myself) is that Cls is quite a slow operation and may be accelerated by the blitter - perhaps it's taking too long and hasn't finished by the time the blitter is required for the Blit command, a situation that Blitz doesn't expect and bombs out as a result. You could try that out by putting a VWait 10 between the Cls and the Blit to see if that helps.

I know I've had a similar issue on the system-friendly side of things trying to erase a window's contents with InnerCLS and then trying to redraw the GUI too quickly afterwards, resulting in corrupted graphics, but I didn't expect that to be the case with Blitz mode commands.
Daedalus is offline  
Old 27 April 2018, 20:41   #7
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
OK, so I installed StackAttack2 (put in the startup-sequence) so hopfully that sorted any possible stack issue.

I rewrote the code to not do anything with GetAShape or drawing directly to bitmaps, removed palette stuff, double buffering stuff, and tried to get to the bare minimum necessary to blit something.

Same results - one frame it draws then HALT3.

Updated code:
Code:
;; Play nicely with WB
WBStartup

;; Everything is a WORD unless otherwise stated
DEFTYPE .w

;; Get a shape
#SH_1 = 1
LoadShape #SH_1, "testshape.ilbm"

;; GO BLITZ MODE
BLITZ

;; Not entirely sure what these do but needed to control the screen
;; Set up a CopList, low-res, 2 bitplane
#CL_1 = 0
InitCopList #CL_1, $002
CreateDisplay #CL_1

;; Allocate the bitmap
#BM_DISP1 = 0
BitMap #BM_DISP1,320,256,2

;; Do until mouse press
While Joyb(0)=0	
	Use BitMap #BM_DISP1
	
	;; Blit
	Blit #SH_1, 0, 0
	
	;; Display it
	VWait
	DisplayBitMap #CL_1, #BM_DISP1
Wend

End
I just don't see what I'm doing wrong. I comment out the blit and it ran fine (drawing a blank bitmap).

The problem appears to be the blit (or qblit - same result).
E-Penguin is offline  
Old 27 April 2018, 22:37   #8
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,335
Hmmmm, I really don't know what's going on here - I tried your first code segment in both AmiBlitz 3 and Blitz 2.1 under WinUAE and it ran fine. The right and bottom edges of the circle are cropped out due to the funky maths of drawing a circle meaning it has a diameter of 11, but it runs fine. My guess is that your version of Blitz is somehow broken, but beyond that I don't know what might cause such a serious crash.
Daedalus is offline  
Old 30 April 2018, 23:30   #9
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
I reinstalled everything from scratch (wb3.1, bb2 with aminet installer) and it now just works. No idea what went on there then. I don't think I did anything different in the installation than the 1st time round. Very odd.

Right, now to make those circles start bouncing around the screen...
E-Penguin 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
Blitting part of a shape? earok Coders. Blitz Basic 3 01 December 2017 03:45
WinUAE v3.3.0 - AGA - Screen "tearing" DamienD support.WinUAE 12 05 August 2016 22:16
Bitmap... "shaking" when blitting shapes on it - Also problems with Display Library Shatterhand Coders. Blitz Basic 18 20 June 2016 19:26
[FOUND: PHANTASIE III!] 2D RPG game with map screen, "black background combat screen" Artifex 28 Looking for a game name ? 1 22 May 2014 17:42
RTG "full-screen" vs. "full windowed" - advantages/disadvantages? ral-clan support.WinUAE 2 19 April 2011 01:15

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:22.

Top

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