Jump to content
IGNORED

Palette Hacking


Robot2600

Recommended Posts

I don't have much experience hacking Atari roms, but I'd like to do some palette changes on a few games. I've done this on the NES before, but I'm lost on the 2600. I'm not sure if Stella can do this or not, but basically I just want to change the 4 colors in Space Invaders. Any help would be greatly appreciated. I've been looking through the hacking utilities and documents for the 2600 and I haven't found anything specifically for palette swapping, probably because it's such a basic thing. But, hey, I gotta start somewhere.

Link to comment
Share on other sites

Space Invaders like many 2600 games changes palette entries multipe times during the display.

 

e.g. the Players are used for score, the invaders, the shields as well as the player's cannons.

 

Using the debug traps in Stella though, you could with some work figure out where colours are stored in a given game and work out where to apply patches to change them.

Link to comment
Share on other sites

Here is the color table in Space Invaders:

 

LFCFF:
;B&W data...
       .byte $0F ; |    XXXX| $FCFF shield
       .byte $0E ; |    XXX | $FD00 UFO
       .byte $0F ; |    XXXX| $FD01 player 1
       .byte $00 ; |        | $FD02 player 2
       .byte $02 ; |      X | $FD03 invaders
       .byte $00 ; |        | $FD04 all missiles
       .byte $04 ; |     X  | $FD05 sky
       .byte $02 ; |      X | $FD06 ground
;Color data...
       .byte $34 ; |  XX X  | $FD07 shield
       .byte $52 ; | X X  X | $FD08 UFO
       .byte $CC ; |XX  XX  | $FD09 player 1
       .byte $F6 ; |XXXX XX | $FD0A player 2
       .byte $14 ; |   X X  | $FD0B invaders
       .byte $0F ; |    XXXX| $FD0C all missiles
       .byte $00 ; |        | $FD0D sky
       .byte $E2 ; |XXX   X | $FD0E ground

 

Tip: in early games like this which utilize the Color/B&W switch for that function, you can often track down color tables by searching for reads from SWCHB ($0282) where bit3 is being tested (the memory bit where the current status of that switch is held). Color/B&W shifting happens within the program, not as a direct hardware result of toggling the switch). A short loop in the program points right at the color table:

 

       lda    SWCHB   ;4 get all switches
       and    #$08    ;2 check Color/B&W only
       tay            ;2 pass to Y index (Y=0 or 
       beq    LF9A6   ;2 branch if it was zero
;set attract mode bitmask:
       lda    #$F7    ;2 Use most all bits for attract mode if color
LF9A6:
       ora    #$07    ;2 ...otherwise, trim off the hue when B&W
       sta    $EE     ;3 store to attract mode mask
       ldx    #$F8    ;2 Set X to begin a loop (counting from $F8 to 0)
LF9AC:
       lda    LFCFF,Y ;4 load color value from Rom (remember, Y=0 or 
       eor    $C7     ;3 flip bits from a counter when in attract mode
       and    $EE     ;3 trim off hue if applicable ($EE = $F7 or $07)
       sta    $E5,X   ;4 and store to color table in Ram ($ED to $E4)
       iny            ;2 bump Y to next index value
       inx            ;2 ...and X too
       bmi    LF9AC   ;2 loop if X didn't roll over to zero yet
Link to comment
Share on other sites

Correction in comments:

      sta    $E5,X   ;4 and store to color table in Ram ($ED to $F4)

Anyway, when executing the display kernel portion, the program simply looks at the color values stored in this ram table instead of looking at the rom table *so all this attract mode business does not need to happen when actually drawing the screen and machine cycles are tight.

 

BTW you can do this in Stella, if you wish. Have the debugger enabled, and press the tilde key (`) when the program is running. On the bottom-right section, you can scroll through the rom program and data. To make a change, double-click a value from the right edge of this window and alter it, then hit enter (not the one from the numpad, tho). You can have Stella write an altered Rom to your HD, as well (right-click anywhere in this window and pick that option)...tho it is stored with an .a26 extension instead of .bin. IIRC, you'll find it in your main identity folder by default (or you can type a full path when typing the filename).

Edited by Nukey Shay
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...