21 July 2021, 21:57 | #1 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Why the screen does not open?
I have this code:
Code:
move.l CUSTOM,a2 move.w DMACONR(a2),d1 ; Old DMA flags in d1. move.l $4,a6 ; Open graphics.library. move.l #graphics_lib,a1 jsr OldOpenLibrary(a6) move.l d0,a3 ; graphics.library handle stored in a3. move.l 38(a6),d2 ; Old Copper settings in d2. move.l a3,a6 ; Wait for finish. jsr WaitTOF(a6) move.l $4,a6 ; Set new DMA and Copper. jsr Disable(a6) move.l copperlist,COP1LCH(a2) move.w #$7fff,DMACON(a2) move.w #SETCLR|COPEN|BPLEN,DMACON(a2) move.l #CIAA+CIAPRA,a1 WaitForLMB: btst #bFIR0,(a1) bne WaitForLMB ... Exit: move.w #$7fff,DMACON(a2) ; Restore old DMA flags. or.w #SETCLR,d1 move.w d1,DMACON(a2) move.l d2,COP1LCH(a2) ; Restore old Copper settings. move.l a3,a6 ; Wait for finish. jsr WaitTOF(a6) move.l $4,a6 ; Close graphics.library. move.l a3,a1 jsr CloseLibrary(a6) moveq #0,d0 ; Exit. jmp Enable(a6) ... graphics_lib: dc.b "graphics.library",0 align 2 copperlist: dc.w BPL1PTH,$0007 dc.w BPL1PTL,$c080 dc.w BPL2PTH,$0007 dc.w BPL2PTL,$dfc0 dc.w BPL1MOD,$0000 dc.w BPL2MOD,$0000 dc.w BPLCON0,(BPUx*2)|COLOR dc.w BPLCON1,$0000 dc.w BPLCON2,$0010 dc.w DIWSTRT,$2c81 dc.w DIWSTOP,$2cc1 dc.w DDFSTRT,$0038 dc.w DDFSTOP,$00d0 dc.w COLOR00,$0000 dc.w COLOR01,$0080 dc.w COLOR02,$00f0 dc.w COLOR03,$0fff dc.w $ffff,$fffe |
21 July 2021, 22:01 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
move.l #copperlist,COP1LCH(a2)
|
21 July 2021, 22:10 | #3 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,033
|
And also, as well as what Ross said, is your copper list in chipmem?
Also at start of code it should be move.l #custom, a2 Also your copper list sets bitplane 1 as $7c080 and bitplane 2 as $7dfc0, yet there is nothing in your code to suggest you are clearing or setting any data at those addresses. Last edited by Galahad/FLT; 21 July 2021 at 22:28. |
21 July 2021, 22:38 | #4 | |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Originally it was that, with the hashmark, but if i do it that way, then the executable becomes corrupted and the Amiga refuses to run it with error 121...
Quote:
CUSTOM.True, but this code is not needed to be system friendly; right after it finishes, a single-task game will take over. |
|
21 July 2021, 22:41 | #5 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
Well, there are quite a few mistakes in fact...
move.w DMACONR(a2),d1 .... or.w #SETCLR,d1 move.w d1,DMACON(a2) and there are system calls in between that don't preserve the value of D1 I just looked quickly, probably there is more |
21 July 2021, 22:50 | #6 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Okay, maybe, but that code is at the exit, when the program closes the graphics library. It does not explain why the screen is not opening, as d1 is not used anywhere else. But thanks for pointing out, d1 and d2 should be stored in a variable.
Edit: Aaaaand if i try to store them in a variable, then the exe is corrupted again and refuses to run with error 121. What is this? Last edited by TCH; 21 July 2021 at 22:57. Reason: error 121 |
21 July 2021, 22:58 | #7 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,457
|
One possibility is the DMACON value.
You set it to Code:
move.w #SETCLR|COPEN|BPLEN,DMACON(a2) Edit: I know this sounds like an odd thing, but DMAEN does not do what you might think if you read the HRM description. The HRM description suggests it activates all the DMA channels in bits 0-8. Instead, it merely makes it so that you can enable the DMA in those bits. Last edited by roondar; 21 July 2021 at 23:12. |
21 July 2021, 23:00 | #8 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
jsr OldOpenLibrary(a6)
move.l d0,a3 ; graphics.library handle stored in a3. move.l 38(a6),d2 ; Old Copper settings in d2. 38(a6) read from execbase... Rewrite it from scratch with more attention. In assembler you cannot afford errors of any kind |
21 July 2021, 23:04 | #9 | |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,033
|
Quote:
Its "working" completely by accident, not by design. Your first line is moving the contents of $dff000 into a2, when the value $dff000 should be in a2. If that line is incorrect, the next line is also wrong as it's not going to be pulling from the correct register. So here is my advice. Cut first two lines. Where you move #$7fff,dmacon(a2), put that before your move of the copper list, dont forget # Ross told you. The two top lines you cut from the top, put them both before the #$7fff,dmacon(a2), not forgetting the # in front of custom. Make sure custom = $dff000 Make sure setclr= $8000 That big setup for DMA before you wait for left mouse button, trim all that out and put in the value $87d0 See how you get on |
|
21 July 2021, 23:04 | #10 |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,130
|
|
21 July 2021, 23:10 | #11 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,457
|
|
21 July 2021, 23:17 | #12 | |||||
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Quote:
Also, this line: move.w DMACONR(a5),DMABackupcauses the program to refuse to run with error 121. Why? It does not help, if i put the value into d1first. Quote:
Quote:
Code:
move.l #CUSTOM,a2 move.w DMACONR(a2),d1 ; Old DMA flags in d1. move.w #$7fff,DMACON(a2) move.l #copperlist,COP1LCH(a2) move.w #$87d0,DMACON(a2) Quote:
Quote:
leawas the correct solution, if i used the hashmark, then error 121 was all i got. Finally, a black screen. I now will test, if the bitplanes are in the right place. Edit: If i try to save the original copper and DMA into variables instead of d1 and d2, then the program crashes... Edit: Galahad, you were right about the $87d0, thanks. Last edited by TCH; 21 July 2021 at 23:27. Reason: too much post, lost track, fixing |
|||||
21 July 2021, 23:27 | #13 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
The following code is the 'correct' version of what you tried to do.
I would never write it like this, too many important parts are missing For the old farts, don't look at me badly, I just got the code and "fixed" it Code:
_LVODisable equ -120 _LVOEnable equ -126 _LVOOldOpenLibrary equ -408 _LVOCloseLibrary equ -414 _LVOWaitTOF equ -270 SECTION code,CODE_C lea $dff000,a2 move.l $4.w,a6 ; Open graphics.library. lea graphics_lib(pc),a1 jsr _LVOOldOpenLibrary(a6) move.l d0,a5 ; graphics.library handle stored in a5. jsr _LVODisable(a6) lea copperlist(pc),a0 move.l a0,$80(a2) move.w #$8000,d0 or.w 2(a2),d0 ; Old DMA flags in d0. move.w #$7fff,$96(a2) move.w #$8380,$96(a2) WaitForLMB: btst #6,$bfe001 bne.b WaitForLMB Exit: move.w #$7fff,$96(a2) move.l 38(a5),$80(a2) ; Restore old Copper settings. move.w d0,$96(a2) ; Restore old DMA flags. jsr _LVOEnable(a6) move.l a5,a1 jsr _LVOCloseLibrary(a6) moveq #0,d0 ; Exit. rts graphics_lib: dc.b "graphics.library",0 even copperlist: dc.w $e0,$0007 dc.w $e2,$c080 dc.w $e4,$0007 dc.w $e6,$dfc0 dc.w $108,$0000 dc.w $10a,$0000 dc.w $100,$2200 dc.w $102,$0000 dc.w $104,$0010 dc.w $8e,$2c81 dc.w $90,$2cc1 dc.w $92,$0038 dc.w $94,$00d0 dc.w $180,$0000 dc.w $182,$0080 dc.w $184,$00f0 dc.w $186,$0fff dc.w $ffff,$fffe Last edited by ross; 21 July 2021 at 23:42. Reason: code pc relative |
21 July 2021, 23:32 | #14 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,457
|
Regardless, it is needed for it to work - I made that mistake so many times
Quote:
About error 121: this means your assembled program is not a proper executable. What VASM/VLINK flags are you using and what version of Kickstart/Workbench are you running your code on? |
|
21 July 2021, 23:45 | #15 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
Quote:
vasm require -kick1hunksto be KS1.x compatible, probably by default it generates reloc tables for KS2.0+ only. I edited the code to be fully pc relative, so problem solved at the root. |
|
22 July 2021, 00:06 | #16 | |||||
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Quote:
LVOprefix? Quote:
Quote:
Quote:
-Fhunkexe -nosymKickStart 1.3, there is no WorkBench. Quote:
-kick1hunks, so roondar must be right about the alignment. If i use -kick1hunks, then it will not be usable under KS 2.0? (Although the targetted game itself has glitches over 1.3, so it is not recommended to run it on KS 2.0+ anyway.) Edit: @ross: You open graphics.library, but do not call anything from it, you've removed the WaitTOFcalls; if it is not needed, why open it? Last edited by TCH; 22 July 2021 at 00:19. |
|||||
22 July 2021, 00:20 | #17 | ||||
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
Quote:
But as I told you in a previous message, and it seems to me that you did not get the point from your reply, it is that when you call the system functions you cannot save variables into d0/d1/a0/a1 because they are scratch registers. Unlike you, I don't have any calls in this piece of code so I took the first free register available Quote:
Quote:
KS2.0 are fully compatiple with old generated hunk. Quote:
About WaitTOF: not the right way to use it, so useless in your case. |
||||
22 July 2021, 00:22 | #18 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
|
|
22 July 2021, 00:28 | #19 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Sorry, in the meantime, i've noticed the
move.l 38(a5),$80(a2)No-no, point taken, i will place them in variables. Aligned ones. :P |
22 July 2021, 00:37 | #20 | ||
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,522
|
Quote:
Quote:
So you have plenty of registers (or stack) to save (temp)variables. |
||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
open chunky screen | grond | Coders. System | 7 | 02 February 2016 16:31 |
Open Screen / Open Font | AGS | Coders. System | 7 | 02 March 2014 05:08 |
Open Amiga Game Database - Open Beta | FrodeSolheim | support.FS-UAE | 3 | 01 May 2013 22:37 |
Amiga 600 not booting... Yellow screen, and Red screen when turning PSU off | jbenam | support.Hardware | 34 | 20 March 2011 22:10 |
Need a small win98 prog, to open and close a directX screen... | keropi | Retrogaming General Discussion | 9 | 25 April 2008 18:43 |
|
|