English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Blitz Basic (https://eab.abime.net/forumdisplay.php?f=126)
-   -   WinUAE gives "HALT3" when blitting a shape to screen (https://eab.abime.net/showthread.php?t=92021)

E-Penguin 26 April 2018 22:16

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


Toni Wilen 27 April 2018 09:21

Halt 3 = CPU instruction opcode fetch from non-existing address. Most common cause is stack return address corruption, too small stack?

E-Penguin 27 April 2018 09:55

Ah, good idea. I'll try again with a larger stack and report back.

Daedalus 27 April 2018 10:04

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

E-Penguin 27 April 2018 11:20

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?

Daedalus 27 April 2018 11:34

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.

E-Penguin 27 April 2018 20:41

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).

Daedalus 27 April 2018 22:37

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.

E-Penguin 30 April 2018 23:30

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


All times are GMT +2. The time now is 02:38.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.07882 seconds with 11 queries