Jump to content
IGNORED

six digit score routine - different behavior in stalla & 8bitworkshop emus


h0trod

Recommended Posts

Hi,

 

I'm working on my first game for the Atari VCS, it's also my first time programming in assembly code of any sort, so it's been a lot of fun.  I'm seeing a discrepancy between how the Stella emulator and the 8bitworkshop IDE (javatari) emulator is rendering my code.

 

In my game, I need to display four playing cards in a horizontal row.  I figured a good way to get started was to experiment with the 6-sprite (48-pixel) score routine, as explained on the Stella List (https://www.biglist.com/lists/stella/archives/199704/msg00137.html) and in Steven Hugg's book.  I think I almost understand it.  The hope is that from there, I should be able to work backwards to a four sprite routine.

 

The problem is that the Stella emulator shows improper spacing between the cards / digits.  The 8bitworkshop IDE spaces them fine.  There's a bit in the code that does a HMOVE for Player1 that looks like it's taking effect on 8bitworkshop, but not in Stella:

 

  lda #$10
  sta HMP1
  sta WSYNC
  sta HMOVE
  sta HMCLR

If I vary the high nibble of the byte I load into HMP1 on Stella, I see no change [*].  If I vary it on 8bitworkshop, I see P1's horizontal position change as I would expect.

Here's the 8bitworkshop rendering:

 

download.thumb.png.fd2caff137a4e66d55bbd78ec9f3df0f.png

 

And the Stella rendering:

 

spacingissue.thumb.png.52d76b5daab10b9c4f86252b872166b1.png

 

I've extracted just the 6 digit score routine part of my code and attached it here: 

 

spacingissue.asm

 

I hope someone can tell me if I'm doing something wrong or one of the emulators is doing something wrong.

 

[*] I got an extreme shift with an extreme value of #$80 in HMP1, but all other values I tried did nothing in Stella.

Link to comment
Share on other sites

16 minutes ago, splendidnut said:

Here's your problem:

 


sta HMOVE
sta HMCLR

You're immediately clearing out any changes to the HMove registers before they get applied... I believe you need ~24 cycles between sta HMOVE and sta HMCLR.

 

Stella is emulating this correctly.

Thank you kindly.  This did the trick!

Link to comment
Share on other sites

Stella matches real hardware:

 

IMG_0981.thumb.jpg.6b278563fa73f8950fe98e9ebbb6e41f.jpg

 

 

32 minutes ago, splendidnut said:

You're immediately clearing out any changes to the HMove registers before they get applied... I believe you need ~24 cycles between sta HMOVE and sta HMCLR.

 

Correct, Stella Programmer's Guide covers this in the last part of section 8.0 Horizontal Motion:

 

1982883418_ScreenShot2020-06-04at4_59_40PM.thumb.png.f3ee86c91c5458f982d43d64ec7a3071.png

 

That means don't write to HMCLR, HMP0, HMP1, HMM0, HMM1, or HMBL for 24 cycles after writing to HMOVE.
 

The delay can be done like this:

  sta WSYNC
  sta HMOVE
  SLEEP 24
  sta HMCLR
  lda #1
  sta VDELP0
  sta VDELP1

 

Though this would be better like this, as it would save 4 bytes of ROM:

  sta WSYNC
  sta HMOVE
  lda #1        ; 2
  sta VDELP0    ; 3
  sta VDELP1    ; 3
  SLEEP 16
  sta HMCLR


If you don't have the guide you can find it in MiniDig's Doc section. I also have it posted in Step 1 of my Collect Tutorial which covers writing a 2K game from scratch.

  • Like 1
Link to comment
Share on other sites

Do note it can be useful at times to break the rules, this bit of code in Stay Frosty writes to HMM1 21 cycles after writing to HMOVE:

 

	ldx #$70
	stx HMM1
	sta WSYNC
	sta HMOVE     ;  3
	SLEEP 16      ; 16 19
	dex           ;  2 21
	stx HMM1      ;  3 24 ; this confuses the TIA and generates stars :-)

 

it creates the starfield in the sky. The Cosmic Ark Stars discussion in the old Stella Mailing List goes into it, and was when support for it was first added to Stella.

 

936995580_ScreenShot2020-06-04at5_14_48PM.thumb.png.e7be81dff7443a807f56332cfd2673dd.png

Link to comment
Share on other sites

Thanks Spiceware.  Your Collect tutorial has been helpful resource!  I have the Stella Programmers Guide - in print, even! - but just missed this bit.  RTFM, as always.  FWIW, Steven Hugg's book misses this in his discussion of score routines, and in his example program at 8bitworkshop (https://8bitworkshop.com/v3.5.1/?file=examples%2Fscore6.a&platform=vcs)

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...