Move code out of sight sprites and into the NOP part of the Trumble routine
This commit is contained in:
parent
1879df09ab
commit
19f7dbf8aa
2 changed files with 127 additions and 91 deletions
|
|
@ -535,6 +535,81 @@ GUARD $80F5 + $08F0
|
||||||
JMP WP1 \ Reset the ball line heap and return from the
|
JMP WP1 \ Reset the ball line heap and return from the
|
||||||
\ subroutine using a tail call
|
\ subroutine using a tail call
|
||||||
|
|
||||||
|
\ ******************************************************************************
|
||||||
|
\
|
||||||
|
\ Name: EraseRestOfPlanet
|
||||||
|
\ Type: Subroutine
|
||||||
|
\ Category: Drawing lines
|
||||||
|
\ Summary: Draw all remaining lines in the ball line heap to erase the rest
|
||||||
|
\ of the old planet
|
||||||
|
\
|
||||||
|
\ ******************************************************************************
|
||||||
|
|
||||||
|
.EraseRestOfPlanet
|
||||||
|
|
||||||
|
LDY XX14 \ Set Y to the offset in XX14, which points to the part
|
||||||
|
\ of the heap that we are overwriting with new points
|
||||||
|
|
||||||
|
CPY XX14+1 \ If XX14 >= XX14+1, then we have already redrawn all of
|
||||||
|
BCS eras1 \ the lines from the old circle's ball line heap, so
|
||||||
|
\ skip the following
|
||||||
|
|
||||||
|
JSR DrawPlanetLine \ Erase the next planet line from the ball line heap
|
||||||
|
|
||||||
|
JMP EraseRestOfPlanet \ Loop back for the next line in the ball line heap
|
||||||
|
|
||||||
|
.eras1
|
||||||
|
|
||||||
|
RTS \ Return from the subroutine
|
||||||
|
|
||||||
|
\ ******************************************************************************
|
||||||
|
\
|
||||||
|
\ Name: BLINE
|
||||||
|
\ Type: Subroutine
|
||||||
|
\ Category: Drawing circles
|
||||||
|
\ Summary: Draw a circle segment and add it to the ball line heap
|
||||||
|
\
|
||||||
|
\ ******************************************************************************
|
||||||
|
|
||||||
|
.PATCH3
|
||||||
|
|
||||||
|
\ These are the instructions from the end of BLINE that
|
||||||
|
\ we move here so there's room for the patch
|
||||||
|
|
||||||
|
LDA K6+2 \
|
||||||
|
STA K5+2 \ * K5(3 2) = screen y-coordinate of this point
|
||||||
|
LDA K6+3 \
|
||||||
|
STA K5+3 \ They now become the "previous point" in the next call
|
||||||
|
|
||||||
|
LDA CNT \ Set CNT = CNT + STP
|
||||||
|
CLC
|
||||||
|
ADC STP
|
||||||
|
STA CNT
|
||||||
|
|
||||||
|
RTS \ Return from the subroutine
|
||||||
|
|
||||||
|
\ ******************************************************************************
|
||||||
|
\
|
||||||
|
\ Name: PL9 (Part 1 of 3)
|
||||||
|
\ Type: Subroutine
|
||||||
|
\ Category: Drawing planets
|
||||||
|
\ Summary: Draw the planet, with either an equator and meridian, or a crater
|
||||||
|
\
|
||||||
|
\ ******************************************************************************
|
||||||
|
|
||||||
|
.PATCH6
|
||||||
|
|
||||||
|
LDA TYPE \ If the planet type is 128 then it has an equator and
|
||||||
|
CMP #128 \ a meridian, so this jumps to PL26 if this is not a
|
||||||
|
BNE P%+5 \ planet with an equator - in other words, if it is a
|
||||||
|
\ planet with a crater
|
||||||
|
|
||||||
|
JMP PL9_2 \ Otherwise this is a planet with an equator and
|
||||||
|
\ meridian, so jump to the equator routine in part 2 of
|
||||||
|
\ PL9
|
||||||
|
|
||||||
|
JMP PL26 \ Jump to the crater routine
|
||||||
|
|
||||||
SAVE "wpls2-plus4.bin", WPLS2, P%
|
SAVE "wpls2-plus4.bin", WPLS2, P%
|
||||||
|
|
||||||
\ ******************************************************************************
|
\ ******************************************************************************
|
||||||
|
|
@ -546,7 +621,7 @@ SAVE "wpls2-plus4.bin", WPLS2, P%
|
||||||
\
|
\
|
||||||
\ ******************************************************************************
|
\ ******************************************************************************
|
||||||
|
|
||||||
ORG $7100
|
ORG $7200
|
||||||
|
|
||||||
GUARD $7300
|
GUARD $7300
|
||||||
|
|
||||||
|
|
@ -699,33 +774,6 @@ GUARD $7300
|
||||||
|
|
||||||
JMP LL78 \ Jump down to part 11
|
JMP LL78 \ Jump down to part 11
|
||||||
|
|
||||||
\ ******************************************************************************
|
|
||||||
\
|
|
||||||
\ Name: EraseRestOfPlanet
|
|
||||||
\ Type: Subroutine
|
|
||||||
\ Category: Drawing lines
|
|
||||||
\ Summary: Draw all remaining lines in the ball line heap to erase the rest
|
|
||||||
\ of the old planet
|
|
||||||
\
|
|
||||||
\ ******************************************************************************
|
|
||||||
|
|
||||||
.EraseRestOfPlanet
|
|
||||||
|
|
||||||
LDY XX14 \ Set Y to the offset in XX14, which points to the part
|
|
||||||
\ of the heap that we are overwriting with new points
|
|
||||||
|
|
||||||
CPY XX14+1 \ If XX14 >= XX14+1, then we have already redrawn all of
|
|
||||||
BCS eras1 \ the lines from the old circle's ball line heap, so
|
|
||||||
\ skip the following
|
|
||||||
|
|
||||||
JSR DrawPlanetLine \ Erase the next planet line from the ball line heap
|
|
||||||
|
|
||||||
JMP EraseRestOfPlanet \ Loop back for the next line in the ball line heap
|
|
||||||
|
|
||||||
.eras1
|
|
||||||
|
|
||||||
RTS \ Return from the subroutine
|
|
||||||
|
|
||||||
\ ******************************************************************************
|
\ ******************************************************************************
|
||||||
\
|
\
|
||||||
\ Name: DrawPlanetLine
|
\ Name: DrawPlanetLine
|
||||||
|
|
@ -854,6 +902,28 @@ GUARD $7300
|
||||||
|
|
||||||
RTS \ Return from the subroutine
|
RTS \ Return from the subroutine
|
||||||
|
|
||||||
|
SAVE "extra-plus4.bin", LLX30, P%
|
||||||
|
|
||||||
|
\ ******************************************************************************
|
||||||
|
\
|
||||||
|
\ Name: Put patches into NOPs in Trumble code
|
||||||
|
\ Type: Subroutine
|
||||||
|
\
|
||||||
|
\ ******************************************************************************
|
||||||
|
|
||||||
|
ORG $1E6A
|
||||||
|
|
||||||
|
GUARD $1EB6
|
||||||
|
|
||||||
|
.TRUMBLE
|
||||||
|
|
||||||
|
JMP PATCHEND \ We inject the following into the batch of NOPs that
|
||||||
|
\ the Plus/4 version has inserted into the middle of the
|
||||||
|
\ Trumble sprite-plotting routine, so this instruction
|
||||||
|
\ just skips over the patches so the routine can still
|
||||||
|
\ run (the Trumble routine does not have an entry point
|
||||||
|
\ within the NOPs, so this is safe)
|
||||||
|
|
||||||
\ ******************************************************************************
|
\ ******************************************************************************
|
||||||
\
|
\
|
||||||
\ Name: DrawNewPlanetLine
|
\ Name: DrawNewPlanetLine
|
||||||
|
|
@ -911,32 +981,6 @@ GUARD $7300
|
||||||
|
|
||||||
RTS \ Return from the subroutine
|
RTS \ Return from the subroutine
|
||||||
|
|
||||||
\ ******************************************************************************
|
|
||||||
\
|
|
||||||
\ Name: BLINE
|
|
||||||
\ Type: Subroutine
|
|
||||||
\ Category: Drawing circles
|
|
||||||
\ Summary: Draw a circle segment and add it to the ball line heap
|
|
||||||
\
|
|
||||||
\ ******************************************************************************
|
|
||||||
|
|
||||||
.PATCH3
|
|
||||||
|
|
||||||
\ These are the instructions from the end of BLINE that
|
|
||||||
\ we move here so there's room for the patch
|
|
||||||
|
|
||||||
LDA K6+2 \
|
|
||||||
STA K5+2 \ * K5(3 2) = screen y-coordinate of this point
|
|
||||||
LDA K6+3 \
|
|
||||||
STA K5+3 \ They now become the "previous point" in the next call
|
|
||||||
|
|
||||||
LDA CNT \ Set CNT = CNT + STP
|
|
||||||
CLC
|
|
||||||
ADC STP
|
|
||||||
STA CNT
|
|
||||||
|
|
||||||
RTS \ Return from the subroutine
|
|
||||||
|
|
||||||
\ ******************************************************************************
|
\ ******************************************************************************
|
||||||
\
|
\
|
||||||
\ Name: PLS22
|
\ Name: PLS22
|
||||||
|
|
@ -986,27 +1030,6 @@ GUARD $7300
|
||||||
|
|
||||||
RTS \ Return from the subroutine
|
RTS \ Return from the subroutine
|
||||||
|
|
||||||
\ ******************************************************************************
|
.PATCHEND
|
||||||
\
|
|
||||||
\ Name: PL9 (Part 1 of 3)
|
|
||||||
\ Type: Subroutine
|
|
||||||
\ Category: Drawing planets
|
|
||||||
\ Summary: Draw the planet, with either an equator and meridian, or a crater
|
|
||||||
\
|
|
||||||
\ ******************************************************************************
|
|
||||||
|
|
||||||
.PATCH6
|
|
||||||
|
|
||||||
LDA TYPE \ If the planet type is 128 then it has an equator and
|
|
||||||
CMP #128 \ a meridian, so this jumps to PL26 if this is not a
|
|
||||||
BNE P%+5 \ planet with an equator - in other words, if it is a
|
|
||||||
\ planet with a crater
|
|
||||||
|
|
||||||
JMP PL9_2 \ Otherwise this is a planet with an equator and
|
|
||||||
\ meridian, so jump to the equator routine in part 2 of
|
|
||||||
\ PL9
|
|
||||||
|
|
||||||
JMP PL26 \ Jump to the crater routine
|
|
||||||
|
|
||||||
SAVE "extra-plus4.bin", LLX30, P%
|
|
||||||
|
|
||||||
|
SAVE "trumble-plus4.bin", TRUMBLE, P%
|
||||||
|
|
|
||||||
|
|
@ -89,9 +89,9 @@ print("[ Read ] elite_+4_unpacked.prg")
|
||||||
# Set the addresses for the extra routines (LLX30, PATCH1, PATCH2) that we will
|
# Set the addresses for the extra routines (LLX30, PATCH1, PATCH2) that we will
|
||||||
# load into unused portiong of the main game code
|
# load into unused portiong of the main game code
|
||||||
|
|
||||||
llx30 = 0x7100
|
llx30 = 0x7200
|
||||||
patch1 = 0x713E
|
patch1 = 0x723E
|
||||||
patch2 = 0x7155
|
patch2 = 0x7255
|
||||||
|
|
||||||
# We now modify the code to implement flicker-free ship drawing. The code
|
# We now modify the code to implement flicker-free ship drawing. The code
|
||||||
# changes are described here, which can be read alongside the following:
|
# changes are described here, which can be read alongside the following:
|
||||||
|
|
@ -304,27 +304,24 @@ insert_binary_file(data_block, 0xA15B + 0x900, "ll78-plus4.bin")
|
||||||
insert_binary_file(data_block, 0xA178 + 0x900, "ll155-plus4.bin")
|
insert_binary_file(data_block, 0xA178 + 0x900, "ll155-plus4.bin")
|
||||||
|
|
||||||
# We now load the three extra routines required by the modifications into the
|
# We now load the three extra routines required by the modifications into the
|
||||||
# memory used by the Trumble sprites, which are not used in the Plus/4 version:
|
# memory used by the explosion and Trumble sprites, which are not used in the
|
||||||
|
# Plus/4 version:
|
||||||
#
|
#
|
||||||
# LLX30
|
# LLX30
|
||||||
# PATCH1
|
# PATCH1
|
||||||
# PATCH2
|
# PATCH2
|
||||||
#
|
# DrawPlanetLine
|
||||||
# PATCH3
|
|
||||||
# PATCH4
|
|
||||||
# PATCH5
|
|
||||||
# PATCH6
|
|
||||||
|
|
||||||
insert_binary_file(data_block, 0x7100, "extra-plus4.bin")
|
insert_binary_file(data_block, 0x7200, "extra-plus4.bin")
|
||||||
|
|
||||||
# We now move on to the routines for drawing flicker-free planets
|
# We now move on to the routines for drawing flicker-free planets
|
||||||
|
|
||||||
# Set the addresses for the extra routines (EraseRestOfPlanet, PATCH4, PATCH5)
|
# Set the addresses for the extra routines (EraseRestOfPlanet, PATCH4, PATCH5)
|
||||||
# that we inserted above
|
# that we inserted above
|
||||||
|
|
||||||
erasep = 0x715B
|
erasep = 0x89BC
|
||||||
patch4 = 0x7229
|
patch4 = 0x1EA0
|
||||||
patch5 = 0x722E
|
patch5 = 0x1EA5
|
||||||
|
|
||||||
# PL9 (Part 1 of 3)
|
# PL9 (Part 1 of 3)
|
||||||
#
|
#
|
||||||
|
|
@ -357,7 +354,12 @@ insert_bytes(data_block, 0x7DE2 + 0x8F0, [
|
||||||
#
|
#
|
||||||
# We have already assembled the modified WPLS2 in BeebAsm and saved it as
|
# We have already assembled the modified WPLS2 in BeebAsm and saved it as
|
||||||
# the binary file wpls2.bin, so now we drop this over the top of the
|
# the binary file wpls2.bin, so now we drop this over the top of the
|
||||||
# existing routine (which is quite a bit longer, so there is room).
|
# existing routine. This binary contains the following routines:
|
||||||
|
#
|
||||||
|
# WPLS2
|
||||||
|
# EraseRestOfPlanet
|
||||||
|
# PATCH3
|
||||||
|
# PATCH6
|
||||||
|
|
||||||
insert_binary_file(data_block, 0x80BB + 0x8F0, "wpls2-plus4.bin")
|
insert_binary_file(data_block, 0x80BB + 0x8F0, "wpls2-plus4.bin")
|
||||||
|
|
||||||
|
|
@ -411,6 +413,17 @@ insert_nops(data_block, 0x8061 + 0x8F0, 1)
|
||||||
|
|
||||||
insert_binary_file(data_block, 0x2974, "bline-plus4.bin")
|
insert_binary_file(data_block, 0x2974, "bline-plus4.bin")
|
||||||
|
|
||||||
|
# We now load the extra routines required by the modifications into the memory
|
||||||
|
# used by the Trumble sprite-drawing routine, which contains a whole raft of
|
||||||
|
# NOPs in the Plus/4 version. We can therefore slip the following routines into
|
||||||
|
# this set of NOPs, adding a JMP beforehand to skip over the patches:
|
||||||
|
#
|
||||||
|
# DrawNewPlanetLine
|
||||||
|
# PATCH4
|
||||||
|
# PATCH5
|
||||||
|
|
||||||
|
insert_binary_file(data_block, 0x1E6A, "trumble-plus4.bin")
|
||||||
|
|
||||||
# All the modifications are done, so write the output file for the modified PRG
|
# All the modifications are done, so write the output file for the modified PRG
|
||||||
|
|
||||||
output_file = open("elite_+4_modified.prg", "wb")
|
output_file = open("elite_+4_modified.prg", "wb")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue