Skip to content

Commit ceb60e7

Browse files
author
Fredrik Ramsberg
committed
Fixed errors in colour handling. Added option -bc to set border colour.
1 parent 6d8e891 commit ceb60e7

File tree

5 files changed

+55
-15
lines changed

5 files changed

+55
-15
lines changed

documentation/colours.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ make.rb has the following switches to control colours:
1010

1111
-sc:(Statusline colour)
1212
Statusline colour: This picks the Z-code colour to use as statusline colour. This is only possible with version 3 story files (z3).
13+
14+
-bc:(Border colour)
15+
Border colour. This picks the Z-code colour to use as border colour.
16+
Special values: 0 = same as background colour (default), 1 = same as foreground colour. If the game itself changes the screen colours,
17+
as it may do in Z5+ games, values 0 and 1 mean the border changes too.
1318

1419
Z-code has a palette of 8 colours, numbered 2-9:
1520

make.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ def build_interpreter()
385385
unless $default_colours.empty? # or $zcode_version >= 5
386386
colourflags += " -DBGCOL=#{$default_colours[0]} -DFGCOL=#{$default_colours[1]}"
387387
end
388+
if $border_colour
389+
colourflags += " -DBORDERCOL=#{$border_colour}"
390+
end
388391
if $statusline_colour
389392
colourflags += " -DSTATCOL=#{$statusline_colour}"
390393
end
@@ -830,20 +833,21 @@ def build_D3(storyname, d64_filename_1, d64_filename_2, d64_filename_3, config_d
830833

831834

832835
def print_usage_and_exit
833-
puts "Usage: make.rb [-S1|-S2|-D2|-D3|-P] [-p:[n]] [-c <preloadfile>] [-o] [-s] [-x] [-r] [-f <fontfile>] "
834-
puts " [-rc:[n]=[c],[n]=[c]...] [-dc:[n]:[n]] [-sc:[n]] [-sp:[n]] <storyfile>"
836+
puts "Usage: make.rb [-S1|-S2|-D2|-D3|-P] [-p:[n]] [-c <preloadfile>] [-o] [-sp:[n]] [-s] [-x] [-r] "
837+
puts " [-f <fontfile>] [-rc:[n]=[c],[n]=[c]...] [-dc:[n]:[n]] [-bc:[n]] [-sc:[n]] <storyfile>"
835838
puts " -S1|-S2|-D2|-D3|-P: specify build mode. Defaults to S1. See docs for details."
836839
puts " -p:[n]: preload a a maximum of n virtual memory blocks to make game faster at start"
837840
puts " -c: read preload config from preloadfile, previously created with -o"
838841
puts " -o: build interpreter in PREOPT (preload optimization) mode. See docs for details."
842+
puts " -sp: Use the specified number of pages for stack (2-9, default is 4)."
839843
puts " -s: start game in Vice if build succeeds"
840844
puts " -x: Use extended tracks (40 instead of 35) on 1541 disk"
841845
puts " -r: Use reduced amount of RAM (-$CFFF). Only with -P."
842846
puts " -f: Embed the specified font with the game. See docs for details."
843847
puts " -rc: Replace the specified Z-code colours with the specified C64 colours. See docs for details."
844848
puts " -dc: Use the specified background and foreground colours. See docs for details."
849+
puts " -bc: Use the specified border colour. 0=same as bg, 1=same as fg. See docs for details."
845850
puts " -sc: Use the specified status line colour. Only valid for Z3 games. See docs for details."
846-
puts " -sp: Use the specified number of pages for stack (2-9, default is 4)."
847851
puts " storyfile: path optional (e.g. infocom/zork1.z3)"
848852
exit 0
849853
end
@@ -865,6 +869,7 @@ def print_usage_and_exit
865869
$default_colours = []
866870
$statusline_colour = nil
867871
$stack_pages = 4 # Should normally be 2-6. Use 4 unless you have a good reason not to.
872+
$border_colour = 0
868873

869874
begin
870875
while i < ARGV.length
@@ -899,6 +904,8 @@ def print_usage_and_exit
899904
$colour_replacements = $1.split(/,/)
900905
elsif ARGV[i] =~ /^-dc:([2-9]):([2-9])$/ then
901906
$default_colours = [$1.to_i,$2.to_i]
907+
elsif ARGV[i] =~ /^-bc:([0-9])$/ then
908+
$border_colour = $1.to_i
902909
elsif ARGV[i] =~ /^-sc:([2-9])$/ then
903910
$statusline_colour = $1.to_i
904911
elsif ARGV[i] =~ /^-sp:([2-9])$/ then

ozmoo.asm

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,23 @@
7979
FGCOL = 9
8080
}
8181

82+
; Border color: 0 = as background, 1 = as foreground, 2-9: specified Z-code colour. Default: as background
83+
!ifndef BORDERCOL {
84+
BORDERCOL = 0
85+
}
86+
!if BORDERCOL = 0 {
87+
BORDER_LIKE_BG = 1
88+
}
89+
!if BORDERCOL = 1 {
90+
BORDER_LIKE_FG = 1
91+
}
92+
8293
!ifndef STATCOL {
8394
STATCOL = FGCOL
8495
}
8596

8697

98+
8799
; * = $0801 ; This must now be set on command line: --setpc $0801
88100

89101
program_start
@@ -325,7 +337,7 @@ z_init
325337
!ifdef Z4PLUS {
326338
lda #8
327339
sta story_start + $1e ; Interpreter number (8 = C64)
328-
lda #64
340+
lda #65
329341
sta story_start + $1f ; Interpreter number. Usually ASCII code for a capital letter (We use @ until the terp is ready for release)
330342
lda #25
331343
sta story_start + $20 ; Screen lines

screen.asm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ init_screen_colours_invisible
1414
init_screen_colours
1515
jsr s_init
1616
ldx zcolours + FGCOL
17-
stx $d020
17+
!ifdef BORDER_LIKE_FG {
18+
stx reg_bordercolour
19+
}
1820
lda colours,x ; Load control character to switch to background colour
1921
+ jsr s_printchar
20-
; lda #$0f
21-
; sta $d020
2222
lda zcolours + BGCOL
23-
sta $d021
23+
sta reg_backgroundcolour
24+
!ifdef BORDER_LIKE_BG {
25+
sta reg_bordercolour
26+
} else {
27+
!ifndef BORDER_LIKE_FG {
28+
lda zcolours + BORDERCOL
29+
sta reg_bordercolour
30+
}
31+
}
2432
!ifdef Z5PLUS {
2533
; store default colours in header
2634
lda #BGCOL ; blue

screenkernal.asm

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ s_erase_line
283283
.stored_x !byte 0
284284
.stored_y !byte 0
285285
.current_screenpos_row !byte $ff
286-
colours !byte 144,5,28,159,156,30,31,158,129,149,150,151,152,153,154,155
287-
zcolours !byte $ff,$ff ; current/default colour
288-
!byte COL2,COL3,COL4,COL5 ; black, red, green, yellow
289-
!byte COL6,COL7,COL8,COL9 ; blue, magenta, cyan, white
286+
colours !byte 144,5,28,159,156,30,31,158,129,149,150,151,152,153,154,155
287+
zcolours !byte $ff,$ff ; current/default colour
288+
!byte COL2,COL3,COL4,COL5 ; black, red, green, yellow
289+
!byte COL6,COL7,COL8,COL9 ; blue, magenta, cyan, white
290290

291291
!ifdef Z5PLUS {
292292
z_ins_set_colour
@@ -297,17 +297,25 @@ z_ins_set_colour
297297
beq .current_foreground
298298
lda zcolours,x
299299
bpl +
300-
lda story_start + header_default_fg_colour ; default colour
300+
ldx story_start + header_default_fg_colour ; default colour
301+
lda zcolours,x
301302
+ tax
303+
!ifdef BORDER_LIKE_FG {
304+
sta reg_bordercolour
305+
}
302306
lda colours,x ; get pet ascii for this colour
303307
jsr s_printchar ; change foreground colour
304308
.current_foreground
305309
ldx z_operand_value_low_arr + 1
306310
beq .current_background
307311
lda zcolours,x
308312
bpl +
309-
lda story_start + header_default_bg_colour ; default colour
310-
+ sta $d021
313+
ldx story_start + header_default_bg_colour ; default colour
314+
lda zcolours,x
315+
+ sta reg_backgroundcolour
316+
!ifdef BORDER_LIKE_BG {
317+
sta reg_bordercolour
318+
}
311319
.current_background
312320
rts
313321
}

0 commit comments

Comments
 (0)