Re: [stella] Games that do bad things to HMOVE...

Subject: Re: [stella] Games that do bad things to HMOVE...
From: bwmott@xxxxxxxxxxxx
Date: Thu, 23 Apr 1998 17:15:16 -0400 (EDT)
> So they waste 71 cycles and hit HMOVE ending on cycle 74.  Thus they 
> are hitting HMOVE two cycles before HBLANK begins.
> Now, the best I can figure is that by hitting HMOVE at this time it
> reduces the amount of motion applied to the objects by 6 clocks.
> So that instead of moving P0 by 8 pixels and P1 by 7 pixels it
> moves them by 2 and 1 pixels.

Well, my guesses were not quite right :-)  I wrote a small test driver
to see how HMOVE works when it's hit at cycle 74 (it's a modified version
of castars.a65) and here's what I found out:

When hitting HMOVE at cycle 74 the upper nibble of HMP1 has the
following meaning:

  0  -8
  1  -9
  2  -10
  3  -11
  4  -12
  5  -13
  6  -14
  7  -15
  8  0
  9  -1
  A  -2
  B  -3
  C  -4
  D  -5
  E  -6
  F  -7

So for the example I gave with Heman it really moves P0 by 0 pixels and 
P1 by -1 pixels.

Hitting HMOVE at cycle 74 does NOT cause HMOVE blanks so it looks like this
is a pretty interesting result.  

The only bad thing I see is that the meaning of HMP0 isn't quite the
same as it is for HMP1.  When the high nibble of HMP0 is F it
moves P0 by -8 instead of -7 :-(

I'm including the code below if you want to give it a try.  Note I
didn't count scanlines so it may roll on your TV.

The program basically scans through the 16 HMP1 values while HMP0 is 
set to $80.  At the very bottom of the screen the lines are positions 
using the same RESPx loop, but hitting HMOVE at the start of HBLANK.


        processor 6502

; TIA (Stella) write-only registers
Vsync		equ	$00
Vblank		equ	$01
Wsync		equ	$02
Nusiz0		equ	$04
Nusiz1		equ	$05
ColuP0          equ     $06
ColuP1          equ     $07
ColuBK          equ     $09
Ctrlpf		equ	$0A
Resp0           equ     $10
Resp1           equ     $11
Grp0		equ	$1b
Grp1		equ	$1c
Hmp0		equ	$20
Hmp1		equ	$21
Hmove           equ     $2A
Hmclr		equ	$2B

; 6532 (RIOT) registers
Swcha           equ     $0280
Swacnt          equ     $0281
Swchb           equ     $0282
Swbcnt          equ     $0283
Intim		equ	$0284
Tim64t		equ	$0296

; ROM definitions
RomStart        equ     $F000
RomEnd          equ     $FFFF
IntVectors      equ     $FFFA

		org 	$F800
; Program initialisation
MotionTable:	dc.b	$00, $10, $20, $30, $40, $50, $60, $70
                dc.b    $80, $90, $a0, $b0, $c0, $d0, $e0, $0f
		SEI				; Disable interrupts.:
		CLD				; Clear "decimal" mode.

		LDX	#$FF
		TXS				; Clear the stack

		LDX	#$28		; Clear the TIA registers ($04-$2C)
		LDA	#$00
		STA	$04,X
                BPL     TIAClear        ; loop exits with X=$FF
		LDX	#$FF
		STA	$00,X		; Clear the RAM ($FF-$80)
                BMI     RAMClear        ; loop exits with X=$7F
		LDX	#$FF
		TXS				; Reset the stack
		STA	Swbcnt		; console I/O always set to INPUT
		STA	Swacnt		; set controller I/O to INPUT

; Main program loop
                LDA     #$02
		STA	Wsync		; Wait for horizontal sync
		STA	Vblank		; Turn on Vblank
                STA	Vsync		; Turn on Vsync
		STA	Wsync		; Leave Vsync on for 3 lines
		STA	Wsync
		STA	Wsync
                LDA     #$00
		STA	Vsync		; Turn Vsync off

                LDA     #43             ; Vblank for 37 lines
		STA	Tim64t		; 43*64intvls=2752=8256colclks=36.2lines

		LDA	Intim
                BNE     VblankLoop      ; wait for vblank timer
		STA	Wsync		; finish waiting for the current line
                STA     Vblank          ; turn off Vblank

                LDA     #$00            ;black
                STA     ColuBK
                LDA     #$0e            ;white
                STA     ColuP0
;                LDA     #$aa
                STA     ColuP1

                LDA     #$AA            ; playfield color
                STA	$8

            	LDA 	#1
		STA	Nusiz0
		STA	Nusiz1

                LDA 	#1        	; reflected playfield
         	STA   	Ctrlpf
		LDA     #$f0
                STA     $d

		LDX	#$00
MotionLoop:	STA	Wsync
		LDA 	#0
		STA	Grp0
		STA	Grp1

		LDA	#$80
		STA	Hmp0
		LDA	MotionTable,X	
		STA	Hmp1

		LDA	#$07
             	STA	Wsync		; waste the rest of the line
pause1:		DEY
		BNE	pause1
		STA	Resp0
		STA	Resp1

; The following loop does the HMOVE at 74 cycles which seems to keep
; the HMOVE blanks from appearing, however, it also changes the movement
; supplied by the HMOVE

		STA	Wsync
		LDY	#$09
pause2:		NOP	
		BPL	pause2
		STA	Hmove

		LDA 	#$AA
		STA	Grp0
		STA	Grp1

Screen:         LDY     #6
B3:             STA     Wsync 
                BNE     B3

		CPX	#$10
		BNE 	MotionLoop

		STA  	Wsync

		LDA	#$80
		STA	Hmp0
		LDA	#$90
		STA	Hmp1

		LDA	#$07
             	STA	Wsync		; waste the rest of the line
pause3:		DEY
		BNE	pause3
		STA	Resp0
		STA	Resp1

		STA	Wsync
		STA	Hmove


                LDY     #40
B4:             STA     Wsync 
                BNE     B4

                LDA     #$02
                STA     Vblank          ;turn on Vblank
                LDX     #30
END:           STA     Wsync
                BNE     END
                JMP     Start

; Set up the 6502 interrupt vector table
		ORG	IntVectors
NMI             dc.w      Cart_Init
Reset           dc.w      Cart_Init
IRQ             dc.w      Cart_Init
;                END

Bradford W. Mott (bwmott@xxxxxxx)          Computer Science Department           North Carolina State University

Archives (includes files) at
Unsub & more at

Current Thread