Keen 3 palette change?
Keen 3 palette change?
I've tried emailing Andy, but he seems absent, but does anyone know enough coding to help with a Keen 3 palette changing patch? I have tried, and failed.
- adurdin
- Site Founder
- Posts: 549
- Joined: Fri Aug 29, 2003 11:27 pm
- Location: Edinburgh, Scotland
- Contact:
It's a fairly simple patch -- the most difficult part of it was finding room for 32 bytes of code (which the multiple background patch provided there). If you can make room in Keen 3, then there should be no problem.
Anyway, here's the annotated patch:
Basically, the code that sets the palette shouldn't need to be altered at all for Keen 2 or 3, as long as the colour palette is written over the "Turbo C++" message. What will change is the location that you put this code, and the CALL instruction that you overwrite the original graphics mode change with.
If you want more info on the EGA/VGA interrupts, have a look at Ralph Brown's Interrupt List (although it lists lots of third-party interrupt functions as well). It's a fantastic resource that I used heavily back in the mid 90's
Anyway, here's the annotated patch:
Code: Select all
%ext ck1
%version 1.31
# This is the color palette: 16 entries of r, g, b (each 0-63)
# Patched over the "Turbo C++" message at DS:0004
# The DS in Keen 1 starts at offset x13050; in Keen 3 at x19820
%patch $13054
05 05 00
14 17 28
21 28 14
14 28 28
28 24 14
26 20 28
28 28 20
20 22 28
11 12 16
31 00 63
39 63 31
31 63 47
63 39 31
55 31 63
58 63 45
45 49 63
# Set the palette when we go into graphics mode
# The original code here is b8 0d 00 cd 10
# Which means of course, MOV AX, x0D; INT x10. (Change to gfx mode D)
# (In Keen 3 this code is at x2FE0)
# We've changed it to CALL x441C; NOP; NOP. (xD5D3 = x441C - x6E46 - x3)
%patch $6E46 $E8 $D3 $D5 $90 $90
# Code to set graphics mode and set the palette
# Location x441C was chosen because the multiple background tile patch
# made some free space there.
# Here we do the following:
# B8 0D 00 MOV AX, x000D # Set mode D (320x200, 16 colour EGA)
# CD 10 INT x10
# B8 12 10 MOV AX, x1012 # Set block of DAC registers
# B9 08 00 MOV CX, x0008 # Number of registers to set (8)
# BB 00 00 MOV BX, x0000 # Starting register
# 8C DA MOV DX, DS # ES:DX should point to
# 8E C2 MOV ES, DX # a table of (R, G, B) bytes, with
# BA 04 00 MOV DX, x0004 # each a value from d00 to d63 (x00 to x3F)
# CD 10 INT x10
# BB 18 00 MOV BX, x0018 # Now start with register x18
# BA 1C 00 MOV DX, x001C # And use the second half of the table
# CD 10 INT x10
# C3 RET
%patch $441C $B8 $0D $00 $CD
$10 $B8 $12 $10 $B9 $08 $00 $BB
$00 $00 $8C $DA $8E $C2 $BA $04
$00 $CD $10 $BB $18 $00 $BA $1C
$00 $CD $10 $C3
# Include this part if the "multiple background tiles" patch is not used
# It gives us 36 spare bytes for the palette-setting code
# This is changing the "Check tile number to get background tile setting"
%patch $4409 $B8 $14 $01 $26 $81 $3F $31
$01 $73 $03 $B8 $8F $00 $26 $89
$07 $E9 $5C $01
%end
If you want more info on the EGA/VGA interrupts, have a look at Ralph Brown's Interrupt List (although it lists lots of third-party interrupt functions as well). It's a fantastic resource that I used heavily back in the mid 90's
It was easy enough to see where the palette was written over; its also where I put the new lights off palette in a patch; and I already have a 'palette change compatible' version of it.
As you said, I screwed up at finding 32 spare bytes, I didn't think of it as 32 bytes spare. I can put this at $153B [Start $153A as $C3] This will of course loose Keen the ability to configure joysticks [Oh NO!] but it gives us more like 320 spare bytes of code.
Righ; I think I should be able to hack something together, as soon as the novocaine from my dentists appointment wears off.
As you said, I screwed up at finding 32 spare bytes, I didn't think of it as 32 bytes spare. I can put this at $153B [Start $153A as $C3] This will of course loose Keen the ability to configure joysticks [Oh NO!] but it gives us more like 320 spare bytes of code.
Righ; I think I should be able to hack something together, as soon as the novocaine from my dentists appointment wears off.