Pimp my Combat 1
Hi there!So, this is just some toying around with the Combat source. The overall plan is to add better "Ace" variants to Combat than my own "Ace" hack did a few years ago :lol:For a start, I used the most advanced iteration of the Combat reverse-engineering from Roger Williams.First thing I noticed, is that it doesn't compile as I find it on my hard disk :-oUpon closer examination, there seems to be a small typo where it reads "BMisDec" instead of "MisDec". Easy fix!(I also quickly made it compile into a binary 100% identical to the one offered at Atari Age.)So for a start, here's a 100% compiling and working source:escape.zipWell, well, so the first tweak that'll happen today will be incredibly simple. I'll bump it up to 4K :)It seems Roger Williams already knew that most people would want to do that, so he already added some advice at the end of his reverse-engineering:
; If you were changing this to a 4K cart, you'd ; want to change this ORG to $FFFC. You might also ; want to move AudPitch out of the interrupt vector... ; ORG $F7FC, $00 .word $f000 ; Reset IRQ ;AudPitch .BYTE $0F, $11 ; Motor sound pitch table by player
Hey, so I'll do just that! I'll replace that passage with:
AudPitch .BYTE $0F, $11 ; Motor sound pitch table by player ORG $FFFC .word START .word START
Ok, compiles... let's check the file size... 4096 bytes... yup that's 4K, yay! :)I start it... and notice a severe bug! :-oSomething is wrong with the playfield at the bottom of the screen!Oha! Next thing I do is checking the original binary. Phew! Thank heavens, the bug is already there! It's not mine! ;)Hm... anyway, let's have a quick look... maybe I can fix it...It's gotta be something to do with the playfield, so I hopp through the source looking at all spots that read "PF"... aha... scoredisplay... blabla... Aha!Found a suspicous passage:
STA ENAM0 ; Clear a bunch of registers. STA ENAM1 STA GRP0 STA GRP1 STA GRP0 ; In case GRP0 isn't COMPLETELY zeroed. STA PF0 STA PF1 STA PF2
It's at the very end of a giant subroutine called "Video OUT -- THE KERNAL".Some register cleanup after everything is drawn. The missiles are disabled, the sprites and the playfield get cleared... the playfield is the last thing that gets cleared... hm...Obviously the playfield gets cleared too soon... I think for the moment it's best to complete the scanline first and *then* clear the playfield:
STA ENAM0 ; Clear a bunch of registers. STA ENAM1 STA GRP0 STA GRP1 STA GRP0 ; In case GRP0 isn't COMPLETELY zeroed. STA WSYNC STA PF0 STA PF1 STA PF2
Ha! Worked! Not bad!Ok, instead of 263 scannlines it's drawing 264 now... which at least PAL users will already consider an improvement as well - Heya! Full color Combat! :)Thinking some more about this... why are all those registers actually cleared at all? Can the sprites go to the very bottom? - No!Can the missiles go to the very bottom? - No!Ah... we can do better than that, or?
STA WSYNC STA PF0 STA PF1 STA PF2 LDA #$02 STA VBLANK
We just clean the playfield and, just in case, turn the electron beam off! :)Ok, for the end of this entry, let's just do some minor code cleanups.I include "macro.h" and replace the mumbo Jumbo at the beginning:
SEI ; Disable interrupts CLD ; Clear decimal bit LDX #StkTop TXS ; Init Stack LDX #$5D JSR ClearMem ; zero out RAM except address $A2 LDA #$10 ; STA SWCHB+1 ; Port B data direction register and STA GameOn ; GameOn (tho not quite a valid value)...
with
CLEAN_START
Next I scan the source code for the VSYNC. Here it comes in a subroutine:
VCNTRL INC CLOCK ; Master frame count timer STA HMCLR ; Clear horizontal move registers. LDA #2 ; Get this ready... STA WSYNC ; for start of next line... STA VBLANK ; Start vertical blank. STA WSYNC STA WSYNC ; and do three lines STA WSYNC STA VSYNC ; Now start vertical sync STA WSYNC STA WSYNC ; and do three lines LDA #0 ; get this ready STA WSYNC STA VSYNC ; End of vertical sync pulse LDA #43 ; And set VBLANK timer STA TIM64T ; with 64 clock interval. RTS
So... what does it do... increment a counter... clear collisions... enable VBLANK... execute VSYNC... and start a timer...Ok. Since I already VBLANK after the kernel (Note to self: Combat has no real overscan region?!?), I remove it here and then replace all the VSYNC stuff with another [stella] standard macro:
VCNTRL INC CLOCK ; Master frame count timer STA HMCLR ; Clear horizontal move registers. VERTICAL_SYNC LDA #43 ; And set VBLANK timer STA TIM64T ; with 64 clock interval. RTS
Actually this little bit of code doesn't really justify a subroutine of it's own anymore, so maybe I'll eliminate it later...Another thing to notice: With getting rid of a bunch of superfluous STA WSYNCs, we're now down to 260 scannlines. Well, at least it's still an even number ;)Ok, so let's have a look back at what I achieved so far:- Fixed two bugs!- Bumped it up to 4K!- Saved a bunch of bytes! It's using more than 30 bytes less than 2K!And here's todays source code:Greetings,Manuel
15 Comments
Recommended Comments