Path: utzoo!attcan!uunet!super!udel!mmdf From: BRENNER_%DULRUU51.BITNET@cunyvm.cuny.edu Newsgroups: comp.sys.amiga Subject: Bug in decision for PAL or NTSC Message-ID: <5714@louie.udel.EDU> Date: 28 Nov 88 19:44:26 GMT Sender: mmdf@udel.EDU Lines: 98 You should read this if your Amiga is a PAL Amiga The following problem has haunted us European Amiga users for a long time now. Approx. once in 30 times the workbench screen won't open to the (normal for PAL) size of 640x256 pixels. This is annoying when one's startup-sequence contains commands to open a new shell to the full screen size and close the initial 640x200 CLI-Window and end with a blank workbench screen. Some people of the Bitnet distribution list Info-Amiga complained too, so it's no problem of my machine. Investigations in the graphics library showed me where the bug lies. The graphics library containes a routine which determines by several reads of the vertical beam position if those extra 56 lines exist, and returns a value containing the information if the machine is a PAL or NTSC Amiga. A listing of this routine follows (The adress is valid for Kickstart version 1.2/33.180 only): Listing: original routine to distinguish between PAL and NTSC fcb058:4eb9 jsr $fc5e62 ;Get vertical beam position fcb05e:2200 move.l D0,D1 fcb060:0c80 cmpi.l #$0000010e,D0 ;beam position greater than $10e ? fcb066:6f04 ble.s $fcb06c ;no, -> fcb068:7004 moveq #$04,D0 ;yes, set PAL bit fcb06a:6028 bra.s $fcb094 ;and exit fcb06c:4eb9 jsr $fc5e62 ;Get vertical beam position fcb072:2200 move.l D0,D1 fcb074:7264 moveq #$64,D1 fcb076:b280 cmp.l D0,D1 ;beam position greater than $64 ? fcb078:6ef2 bgt.s $fcb06c ;no, try again -> fcb07a:4eb9 jsr $fc5e62 ;Get vertical beam position fcb080:2200 move.l D0,D1 fcb082:0c81 cmpi.l #$0000010e,D1 ;beam position greater than $10e? fcb088:6f02 ble.s $fcb08c ;no, -> fcb08a:60dc bra.s $fcb068 ;yes, set PAL bit and exit fcb08c:7032 moveq #$32,D0 fcb08e:b081 cmp.l D1,D0 ;beam position greater than $32 ? fcb090:6de8 blt.s $fcb07a ;yes, test again for >$10e -> fcb092:7001 moveq #$01,D0 ;no, set NTSC bit fcb094:4e75 rts * Load vertical beam position into D0 (here lies the BUG) fc5e62:2039 move.l $dff004,D0 ;read VPOSR+VHPOSR as longword fc5e68:e080 asr.l #8,D0 fc5e6a:0280 andi.l #$000001ff,D0 ;9-Bit beam position into D0 fc5e70:4e75 rts The problem lies in the read of the longword from VPOSR+VHPOSR. This SHOULD give a value between 0 and $1ff. But what if the beam is at the rightmost position of line $FF when the longword is read? Perhaps the high word containing the ninth bit of the vertical position is read as 0 and then, after the counter advanced to $100 the low word is read as $00xx, the high byte containing the lower 8 bits of the vertical beam position. So a total value of 0 is read for the position which will result in a run thru adresses $fcb08e, $fcb090 and $fcb092 and an erraneous set of the NTSC bit. As an alternative I propose the following routine (hope Multitasking is off during this time) which works fine now for some time. * New PAL/NTSC - Testroutine for Kickstart 1.2/33.180 * Aztec-C Assembler V3.4a * (the following three lines are for my Kickstart changer) DC.W $4AFC ;Magic Word DC.L $FCB058 ;Startadress DC.L Ende-Start ;Length in Bytes Start: MOVEQ #$04,D1 ;PAL is default, set PAL bit WaitLoop1: JSR $FC5E62 ;Get vertical beam position CMP.B #$20,D0 ;Position == $20 or $120 ? BNE.S WaitLoop1 ;no, wait -> AND.W #$100,D0 ;Position == $120 ? BNE Ready ;yes, it's PAL, -> Ready WaitLoop2: JSR $FC5E62 ;Get vertical beam position CMP.B #$1F,D0 ;Position == $1F oder $11F ? BNE WaitLoop2 ;no, wait -> AND.W #$100,D0 ;Position == $11F ? BNE Ready ;yes, it's PAL, -> Ready MOVEQ #$01,D1 ;no, it's NTSC, Set NTSC bit Ready: MOVE.L D1,D0 ;Return the video type RTS Ende: Last note: The bug is still present in Kickstart 1.3/34.5! -Martin @ @ ---------------------------------------------------------------------- ===V=== "This message still Beta testing - don't blame me for bugs!" // !^! -Martin (BRENNER_M@DULRUU51.BITNET) Uni Ulm/F.R.Germany \X/AMIGA ^ ^ ---------------------------------------------------------------------- %SYSTEM-W-POWERFAIL, power failure occurred