[comp.sys.m6809] CoCo3 pmode4 games

kato@potpourri.UUCP (Carlos Santiago) (07/23/87)

   I recently purchased a CoCo 3 after owning a CoCo 1 for 6 years. 
I enjoy playing video games on my CoCo 3, but those games that
use artifacting only display in black an white. For the pasted
two weeks I have been converting these games to display in color.
For those interested the procedure is simple, the only requirement
is that you have a position independent  monitor program. 
  The following procedure assumes a good knowledge of coco graphics
and assembly language.

1. Find the START, END, and EXEC address of the game.

2. Load the monitor program in above the diskbasic roms at
   address $E000.  You may need to run a rom to ram program to
   get access to this area of memory. This allows any game to reside
   in memory at the same time as the monitor program since most ML
   programs load into memory from $E00 to $7FFF(not all addresses
   are used by all programs).

3. Load the a copy of the game to be modified into memory.

4. Search for any occurrences of $FF22 in the area occupied by
   the game. This the address of the PIA that is used to control
   the video mode. 

5. Disassemble the code at the addresses before the address where the 
   $FF22 was found.

6. If the code is a LDA #$FX, LDB #$FX where X is a hex value from 8
   to F, change the code to LDA #$EX or LDB #$EX. Change all occurrences.
   NOTE: only change the code if it is followed by a STA $FF22 or a
   STB $FF22. This change in code changes the graphics mode from
   256 X 192 two color to 128 X 192 four color.

7. The following lines of assembly code must be added to patch the
   palette registers for the proper PMODE4 colors ie. BLACK, WHITE,
   RED, and BLUE. Note these are the colors I used you may select
   any 4 colors from the 64 available.
 
  Find an area in memory that is not used by the game but within the
  range of $E00 and $7FFF. If this is range is completely used by the 
  game an area of memory that is not used within the game code must
  be found. The occurrence of $FF, $00, $FF, $00...... in memory
  usually indicates unused memory.
  

  STARTN  LDD #$0009      $00 black  $09 blue
          STD $FFB4       $FFB4 palette 5 $FFB5 palette 6
          LDD #$243F      $24 red    $3f white
          STD $FFB6       $FFB6 palette 6 $FFB7 palette 7
          BRA START       START normal start address of game

8. Disassemble the new code from STARTN insure the code is correct.
   The BRA instruction may be converted to a LBRA this is not a
   problem. Write down the address of the label STARTN this
   is the new EXEC address of the game. If the code is added at
   the end of the game, find the address after the BRA START and
   write it down, this will be the new END address.

9. Save the game using the old START, the new EXEC, and the new END addresses.



  Precautions.

  When saving the game use a different name, the reason for this is twofold.
  First if the game is patched wrong you still have a backup copy. Next 
  giving the game a new name such racer3 or marble3 allow you to find
  the programs patched for the COCO 3 much easier.

  If the program uses all address from $E00 to $7FFF this patch may not
  work the first time. If the game hangs the machine you must find
  another area in memory to use for the patch.
 
  Although this method works fine with most games, it does not work on all
  games, simply because some games setup the graphics mode differently.
  By this I mean that the value for the graphics mode is not always a literal
  value that is an immediate operand to a load instruction. It may
  be load from a location in low memory such as page 0.

  If you prefer other colors, the values stored at $FFB4-$FFB7 are
  decode in the following manner:

  BIT   7 6 5 4 3 2 1 0
        0 0 R G B R G B  Where RGB is RED, GREEN, AND BLUE hence $09 is blue.
                         Different combinations of these bits yield a total
                         of 64 different colors.

-- 
                  Gould, CSD, Home of the Firebreathers 
                    The opinions expressed are my own.
                   ...siesmo!gould!csantiago
                   ...mcnc!rti-sel!gould!potpourri!kato