castleraider
changeset 300:2cc46aa21ee8
Moved the in-game text into the loader code for relocation into the
temporary area before the game is loaded.
Ensured that copying works across page boundaries.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sat Apr 05 19:04:10 2014 +0200 |
| parents | fee41b81b008 |
| children | f2d5e8222b1a |
| files | build.py code.oph loader.oph plotting.oph |
| diffstat | 4 files changed, 88 insertions(+), 43 deletions(-) [+] |
line diff
1.1 --- a/build.py Sat Apr 05 18:32:11 2014 +0200 1.2 +++ b/build.py Sat Apr 05 19:04:10 2014 +0200 1.3 @@ -148,6 +148,64 @@ 1.4 else: 1.5 level_file = sys.argv[3] 1.6 1.7 + # Encode the in-game title data. 1.8 + title_data_oph = "title_data:\n" 1.9 + 1.10 + title_rows = 0 1.11 + for line in open("title.txt").readlines(): 1.12 + 1.13 + line = line.rstrip("\n") 1.14 + title_data_oph += ".byte " 1.15 + 1.16 + for i in range(0, 40, 4): 1.17 + 1.18 + byte = 0 1.19 + shift = 0 1.20 + for char in line[i:i + 4]: 1.21 + byte = byte | (".@#+".index(char) << shift) 1.22 + shift += 2 1.23 + 1.24 + title_data_oph += "$%02x" % byte 1.25 + if i < 36: 1.26 + title_data_oph += ", " 1.27 + 1.28 + title_data_oph += "\n" 1.29 + title_rows += 1 1.30 + 1.31 + title_data_oph += ( 1.32 + "\n" 1.33 + "title_end:\n" 1.34 + ".alias title_length [title_end - title_data]\n" 1.35 + "\n" 1.36 + ) 1.37 + 1.38 + title_text = [(26, 31, 3, 6, 17, 3, "Retro Software"), 1.39 + (31, 6, 8, "presents"), 1.40 + (31, 2, 27, 17, 2, "Press ", 17, 3, "SPACE/FIRE"), 1.41 + (31, 6, 29, 17, 2, "to play")] 1.42 + 1.43 + title_data_oph += 'game_title_text:\n' 1.44 + in_game_title_text_length = 0 1.45 + 1.46 + for line in title_text: 1.47 + 1.48 + in_game_title_text_values = [] 1.49 + 1.50 + for piece in line: 1.51 + 1.52 + if type(piece) == int: 1.53 + in_game_title_text_length += 1 1.54 + in_game_title_text_values.append(str(piece)) 1.55 + else: 1.56 + in_game_title_text_length += len(piece) 1.57 + in_game_title_text_values.append('"' + piece + '"') 1.58 + 1.59 + title_data_oph += ".byte " + ", ".join(in_game_title_text_values) + "\n" 1.60 + 1.61 + title_data_oph += 'game_title_text_end:\n' 1.62 + 1.63 + open("title-data.oph", "w").write(title_data_oph) 1.64 + 1.65 # Memory map 1.66 memory_map = { 1.67 "code start": 0x0e00, 1.68 @@ -195,10 +253,11 @@ 1.69 monster_right_max_offset = monster_information + 5 1.70 1.71 # Working data 1.72 - # Place working data in page C (the user defined characters buffer). 1.73 + # Place working data in pages B (the soft key buffer) and C (the user 1.74 + # defined characters buffer). 1.75 1.76 # Monster positions 1.77 - monster_positions_address = 0xc00 1.78 + monster_positions_address = 0xb00 1.79 1.80 # Working information about tile visibility. 1.81 tile_visibility_address = monster_positions_address + 0x14 1.82 @@ -221,6 +280,8 @@ 1.83 # loader. 1.84 title_data_address = initial_row_offsets + 0x10 1.85 1.86 + in_game_title_text_address = title_data_address + (title_rows * 10) 1.87 + 1.88 # Permanent data 1.89 1.90 # Level data 1.91 @@ -315,34 +376,6 @@ 1.92 1.93 title_data = makesprites.read_title("images/title.png") 1.94 1.95 - # Encode the in-game title data. 1.96 - title_data_oph = "title_data:\n" 1.97 - 1.98 - title_rows = 0 1.99 - for line in open("title.txt").readlines(): 1.100 - 1.101 - line = line.rstrip("\n") 1.102 - title_data_oph += ".byte " 1.103 - 1.104 - for i in range(0, 40, 4): 1.105 - 1.106 - byte = 0 1.107 - shift = 0 1.108 - for char in line[i:i + 4]: 1.109 - byte = byte | (".@#+".index(char) << shift) 1.110 - shift += 2 1.111 - 1.112 - title_data_oph += "$%02x" % byte 1.113 - if i < 36: 1.114 - title_data_oph += ", " 1.115 - 1.116 - title_data_oph += "\n" 1.117 - title_rows += 1 1.118 - 1.119 - title_data_oph += "\ntitle_end:\n.alias title_length [title_end - title_data]\n" 1.120 - 1.121 - open("title-data.oph", "w").write(title_data_oph) 1.122 - 1.123 # Create the contents of a file containing constant values. 1.124 1.125 constants_oph = ( 1.126 @@ -557,8 +590,11 @@ 1.127 constants_oph += ( 1.128 ".alias title_data_address $%x\n" 1.129 ".alias title_rows %i\n" 1.130 + ".alias in_game_title_text_address $%x\n" 1.131 + ".alias in_game_title_text_length %i\n" 1.132 "\n" 1.133 - ) % (title_data_address, title_rows) 1.134 + ) % (title_data_address, title_rows, in_game_title_text_address, 1.135 + in_game_title_text_length) 1.136 1.137 scenery_rows = 16 1.138 extra_rows = 7
2.1 --- a/code.oph Sat Apr 05 18:32:11 2014 +0200 2.2 +++ b/code.oph Sat Apr 05 19:04:10 2014 +0200 2.3 @@ -32,10 +32,10 @@ 2.4 2.5 ldx #0 2.6 title_text_loop: 2.7 - lda title_text,x 2.8 + lda in_game_title_text_address,x 2.9 jsr $ffee 2.10 inx 2.11 - cpx #[title_text_end - title_text] 2.12 + cpx #in_game_title_text_length 2.13 bne title_text_loop 2.14 2.15 ; Wait for the SPACE key or fire button to be pressed. 2.16 @@ -1106,10 +1106,6 @@ 2.17 ; clc 2.18 ; rts 2.19 2.20 -title_text: .byte 26, 31, 2, 26, 17, 2, "Press ", 17, 3, "SPACE/FIRE" 2.21 - .byte 31, 6, 28, 17, 2, "to play" 2.22 -title_text_end: 2.23 - 2.24 .include "screen.oph" 2.25 .include "plotting.oph" 2.26 .include "scrolling.oph"
3.1 --- a/loader.oph Sat Apr 05 18:32:11 2014 +0200 3.2 +++ b/loader.oph Sat Apr 05 19:04:10 2014 +0200 3.3 @@ -475,9 +475,13 @@ 3.4 3.5 init_load_window_vdu_bytes: .byte 28,0,30,19,26,12 3.6 3.7 -title_text: .byte " Copyright (C) 2014", 13, 10 3.8 +title_text: .byte 17, 1 3.9 + .byte " Copyright (C) 2014", 13, 10 3.10 + .byte 17, 2 3.11 .byte " David Boddie", 13, 10 3.12 + .byte 17, 3 3.13 .byte " for Retro Software", 13, 10 3.14 + .byte 17, 2 3.15 .byte "GNU GPL v.3 or later" 3.16 title_text_end: 3.17 3.18 @@ -512,10 +516,16 @@ 3.19 sta $71 3.20 clc 3.21 3.22 - inc $72 ; The destination address falls within a page, so we only need 3.23 - ; to update the lower byte of the address. 3.24 + lda $72 3.25 + adc #1 3.26 + sta $72 3.27 + lda $73 3.28 + adc #0 3.29 + sta $73 3.30 + clc 3.31 + 3.32 inx 3.33 - cpx #title_length 3.34 + cpx #[title_length + in_game_title_text_length] 3.35 bne move_title_data_loop 3.36 3.37 clc
4.1 --- a/plotting.oph Sat Apr 05 18:32:11 2014 +0200 4.2 +++ b/plotting.oph Sat Apr 05 19:04:10 2014 +0200 4.3 @@ -1535,9 +1535,12 @@ 4.4 ldx $80 ; Load the row number. 4.5 jsr read_screen_address_bank2 ; Sets $72,$73 from A and X. 4.6 4.7 + lda $72 4.8 + sec 4.9 + sbc #$80 4.10 + sta $72 4.11 lda $73 4.12 - sec 4.13 - sbc #$05 4.14 + sbc #$02 4.15 sta $73 4.16 clc 4.17
