h0trod Posted June 4, 2020 Share Posted June 4, 2020 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: And the Stella rendering: 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. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted June 4, 2020 Share Posted June 4, 2020 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. 4 Quote Link to comment Share on other sites More sharing options...
h0trod Posted June 4, 2020 Author Share Posted June 4, 2020 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! Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 4, 2020 Share Posted June 4, 2020 Stella matches real hardware: 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: 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. 1 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 4, 2020 Share Posted June 4, 2020 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. Quote Link to comment Share on other sites More sharing options...
h0trod Posted June 5, 2020 Author Share Posted June 5, 2020 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) 1 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 5, 2020 Share Posted June 5, 2020 Yeah, it's easy for "modern eyes" to miss that in the manual when first starting out as "motion registers" aren't something we're familiar with. I've pinged him on Twitter about it: 1 Quote Link to comment Share on other sites More sharing options...
h0trod Posted June 5, 2020 Author Share Posted June 5, 2020 Thanks, and followed! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.