From 0413bef00376968d37fdf097313bacc890a1ba60 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Thu, 18 Jul 2024 17:11:34 +1000 Subject: [PATCH] Get DHGR working again (requires manual edit to Makefile and star_blazer.asm) --- star_blazer/Makefile | 17 +++++- star_blazer/star_blazer.asm.patch | 97 +++++++++++++++++-------------- 2 files changed, 67 insertions(+), 47 deletions(-) diff --git a/star_blazer/Makefile b/star_blazer/Makefile index f9223e9..bd30e14 100644 --- a/star_blazer/Makefile +++ b/star_blazer/Makefile @@ -26,6 +26,21 @@ star_blazer.dsk: ../util/bootable.dsk star_blazer_pack_rev.a2bin #../loader/star_blazer_pack_rev.a2bin # ../utils/a2_pack.py ${LOAD_ADDR} ../loader/lzss_unpack_rev_aux_mem.bin $< $@ # -diff -q ../loader/star_blazer_pack_rev.a2bin $@ +#star_blazer.ihx: star_blazer.rel +# ${ASLINK} -nmu \ +#-a zpage=0 \ +#-a data0=0x200 \ +#-a udata0=0x400 \ +#-a text0=0xa00 \ +#-a data1=0x1f80 \ +#-a data2=0x4000 \ +#-a data3=0x4800 \ +#-a data4=0x5c00 \ +#-a data5=0x9100 \ +#-a udata1=0xab00 \ +#-a text2=0xb880 \ +#-a data6=0x15c00 \ +#-i+$@ $< # HGR star_blazer_pack_rev.a2bin: \ @@ -34,9 +49,7 @@ star_blazer.ihx \ ../loader/star_blazer_pack_rev.a2bin ../utils/a2_pack.py ${LOAD_ADDR} ../loader/lzss_unpack_rev.bin $< $@ -diff -q ../loader/star_blazer_pack_rev.a2bin $@ - star_blazer.ihx: star_blazer.rel - # add for DHGR: -b data5=0x15c00 ${ASLINK} -nmu \ -a zpage=0 \ -a data0=0x200 \ diff --git a/star_blazer/star_blazer.asm.patch b/star_blazer/star_blazer.asm.patch index ee550fd..d3aa2d9 100644 --- a/star_blazer/star_blazer.asm.patch +++ b/star_blazer/star_blazer.asm.patch @@ -1,5 +1,5 @@ ---- star_blazer.asm0 2024-07-18 14:21:12.880706291 +1000 -+++ star_blazer.asm 2024-07-18 14:25:29.178660712 +1000 +--- star_blazer.asm0 2024-07-18 15:50:40.764029819 +1000 ++++ star_blazer.asm 2024-07-18 17:11:18.945116204 +1000 @@ -1,3 +1,10 @@ +UNREACHABLE = 1 +DHGR = 0 @@ -87,7 +87,7 @@ ; 24-bit register, repurposed for divide routine as ; accumulator: divisor ; accumulator + 1: remainder -@@ -410,20 +456,20 @@ +@@ -419,20 +465,20 @@ ; object1080_velocity_scale_for_position_(hi|lo) ; returns a = high byte of scaled value get_scaled_object_velocity_x_to_a: @@ -114,7 +114,7 @@ ldy *temp ; 0b79 r jsr multiply_ya_by_accumulator_optimized ; 0b7b r tya ; 0b7e r -@@ -438,46 +484,46 @@ +@@ -447,46 +493,46 @@ copy_object_position_plus_scaled_velocity: jsr get_scaled_object_velocity_x_to_a ; 0b82 r clc ; 0b85 r @@ -177,7 +177,7 @@ rts ; 0be1 r ; call with y = object to calculate for ; uses coefficient from the following table: -@@ -520,14 +566,14 @@ +@@ -529,14 +575,14 @@ copy_scaled_object_velocity_rotate_90: jsr get_scaled_object_velocity_y_to_ya ; 0c1f r jsr neg_ya ; 0c22 r @@ -196,7 +196,7 @@ ldy *y_save ; 0c38 r rts ; 0c3a r copy_scaled_object_velocity_rotate_180: -@@ -546,15 +592,15 @@ +@@ -555,15 +601,15 @@ rts ; 0c57 -> 0c59 -> 0fcb r s=f0 copy_scaled_object_velocity_rotate_270: jsr get_scaled_object_velocity_y_to_ya ; 0c5a r @@ -216,7 +216,7 @@ ldy *y_save ; 0c73 r rts ; 0c75 r horizontal_collision: -@@ -596,8 +642,8 @@ +@@ -605,8 +651,8 @@ horizontal_collision_and_zero: jsr horizontal_collision ; 0cc4 r lda #0x00 ; 0cc7 r @@ -227,7 +227,7 @@ rts ; 0ccf r vertical_collision_and_zero: jsr vertical_collision ; 1015 -> 0cd0 -> 0c9d r s=f5 -@@ -919,9 +965,10 @@ +@@ -928,9 +974,10 @@ bcs ucode_decimal_set_save ; 0ebf r ucode_decimal_set_mission_specific_value: ldy *decimal + 6 ; 0ec1 r @@ -240,7 +240,7 @@ tay ; 0eca r pla ; 0ecb r bcs ucode_decimal_set_save ; 0ecc r -@@ -1288,7 +1335,7 @@ +@@ -1297,7 +1344,7 @@ tsx ; 1095 -> 1097 -> 1098 r stx *ucode_sp ; 1097 -> 1098 -> 109a r ldx *ucode_x_save_c9 ; 1098 -> 109a -> 109c r @@ -249,7 +249,7 @@ sta *ucode_object_state ; 109c -> 109f -> 10a1 r ; alternative entry point for ucode_execute_words that comes from scoring? ucode_execute_words_entry: -@@ -1320,7 +1367,7 @@ +@@ -1329,7 +1376,7 @@ ; jsr execute_object1080_ucode_countdown ; bpl rts_15d6 ucode_execute_words_done: @@ -258,7 +258,7 @@ rts ; 10cd -> 10d0 -> 123e,143a,1615,1629,1633,1649,165b,1759 r s=f7..fd,02 ; it seems to read values from table at ucode_ptr_c0 with some complicated ; indirection (value from table = index to use for next read from table?) and -@@ -1837,16 +1884,20 @@ +@@ -1850,16 +1897,20 @@ bpl loc_14c9 ; 14a0 -> 14a3 -> 14a5,14c9 r n=0..1 iny ; 14a3 -> 14a5 -> 14a6 r bne ucode_test_fire_all_objects_active ; 14a5 -> 14a6 -> 149b r z=0 @@ -279,8 +279,8 @@ +.endif ; opcode is followed by null-terminated list of objects to test ; note: some of these opcodes never executed in the trace - ; references to object1080_y1 + 0x60 should be object1080_state - 0x10 -@@ -1880,17 +1931,21 @@ + ; 0x01 loc_149b test that all objects are active (object1080_state >= 0x80) +@@ -1892,17 +1943,21 @@ bmi loc_14c9 ; 14d5 -> 14d8 -> 14da r n=0 iny ; 14d8 -> 14da -> 14db r bne ucode_test_fire_any_object_active ; 14da -> 14db -> 14d0 r z=0 @@ -303,7 +303,7 @@ test_object_fire_in_state_f0: lda object6080_fire_count - 0x60,x ; 1668 -> 14ef -> 14f2 r x=60..7f beq test_object_fire_false ; 14ef -> 14f2 -> 14f4,153f r z=0..1 -@@ -2254,10 +2309,35 @@ +@@ -2266,10 +2321,35 @@ sta *button_state ; 17ce r rts_17d0: rts ; 17ab,17ca -> 17d0 -> 1768,176f r s=fd @@ -340,7 +340,7 @@ ldx #0x01 ; 17db r 0$: jsr ROM_PREAD ; 17dd r cpy #0xff ; 17e0 r -@@ -2268,7 +2348,12 @@ +@@ -2280,9 +2360,17 @@ sta bvar_179e ; 17e9 r sta bvar_17a3 ; 17ec r sta bvar_1e0e ; 17ef r @@ -352,9 +352,14 @@ +.endif + jmp (vec_init_game) ; 17d9 -> 17f2 -> 1708 r ++; above code is a bit bigger for DHGR so we are past address 0x1800 by here ++.ifeq DHGR .area text1 ++.endif -@@ -2336,10 +2421,12 @@ + divide_a_by_y: + sta *accumulator + 1 ; 0a90,0aa0,0ab5,0ad5 -> 1800 -> 1802 r +@@ -2348,10 +2436,12 @@ lda *result + 1 ; 186e r ldy *result + 2 ; 1870 r rts ; 1872 r @@ -367,7 +372,7 @@ random_init: lda *random_seed ; 16ae -> 187a -> 187c r ora #0x01 ; 187a -> 187c -> 187e r -@@ -2499,16 +2586,30 @@ +@@ -2511,16 +2601,30 @@ ldx #>HIRES_SCREEN ; 199b -> 199d -> 199f r stx *video_line_ptr + 1 ; 199d -> 199f -> 19a1 r tay ; 199f -> 19a1 -> 19a2 r @@ -399,7 +404,7 @@ rts ; 19b5 -> 19b8 -> 1713 r s=fd video_clear_rectangle: ldx *clip_y0 ; 1064 -> 19b9 -> 19bb r -@@ -2516,8 +2617,20 @@ +@@ -2528,8 +2632,20 @@ sta *video_line_ptr ; 19bb -> 19be -> 19c0 r lda video_line_table_hi - 0x20,x ; 19be -> 19c0 -> 19c3 r x=28..cf sta *video_line_ptr + 1 ; 19c0 -> 19c3 -> 19c5 r @@ -420,7 +425,7 @@ 1$: sta (*video_line_ptr),y ; 19c7,19ce -> 19c9 -> 19cb r y=6c..93 iny ; 19c9 -> 19cb -> 19cc r cpy *clip_x1 ; 19cb -> 19cc -> 19ce r y=6d..94 -@@ -2566,6 +2679,7 @@ +@@ -2579,6 +2695,7 @@ sta object1080_y0 - 0x10,x ; 1a1b -> 1a1e -> 1a21 r x=10..7f adc #0x01 ; 1a1e -> 1a21 -> 1a23 r c=0..1 d=0 sta object1080_y1 - 0x10,x ; 1a21 -> 1a23 -> 1a26 r x=10..7f @@ -428,7 +433,7 @@ rts ; 1a23 -> 1a26 -> 1076,1179,1602 r s=f1..f9,02 pixel_data_table_left: .db 0x83 ; 1a27 r -@@ -2648,14 +2762,17 @@ +@@ -2661,14 +2778,17 @@ lda object1080_onscreen_shape_ptr_hi - 0x10,x ; 1aa5 -> 1aa7 -> 1aaa r x=20..4f ora (*video_line_ptr),y ; 1aa7 -> 1aaa -> 1aac r y=6d..93,02 sta (*video_line_ptr),y ; 1aaa -> 1aac -> 1aae r y=6d..93,02 @@ -446,7 +451,7 @@ lda object1080_y0 - 0x10,x ; 1ab9 -> 1abb -> 1abe r x=14..77 cmp object1080_y1 - 0x10,x ; 1abb -> 1abe -> 1ac1 r a=11..d4 x=14..77 bcs rts_1aae ; 1abe -> 1ac1 -> 1ac3 r c=0 -@@ -2708,7 +2825,12 @@ +@@ -2721,7 +2841,12 @@ stx *x_save ; 1b32 -> 1b35 -> 1b37 r lda *draw_y ; 1b35 -> 1b37 -> 1b39 r cmp *clip_y0 ; 1b37 -> 1b39 -> 1b3b r a=11..d4 @@ -459,7 +464,7 @@ lda *clip_y1 ; 1b3b -> 1b3d -> 1b3f r cmp *draw_y1 ; 1b3d -> 1b3f -> 1b41 r a=d0 bcc 8$ ; 1b3f -> 1b41 -> 1b43,1b83 r c=0..1 -@@ -2719,16 +2841,59 @@ +@@ -2732,16 +2857,59 @@ cmp *draw_x1 ; 1b49 -> 1b4b -> 1b4d r a=94 bcc 8$ ; 1b4b -> 1b4d -> 1b4f,1b83 r c=0..1 lda object1080_onscreen_shape_ptr_lo - 0x10,x ; 1b4d -> 1b4f -> 1b52 r x=14..77 @@ -519,7 +524,7 @@ 6$: .db 0xbd ; 1b69,1b76 -> 1b6b -> 1b6e r "lda bvar_6f9f,x" x=00..39 7$: .dw 0x6f9f ; 1b6c rw ora (*video_line_ptr),y ; 1b6b -> 1b6e -> 1b70 r y=6c..93 -@@ -2745,16 +2910,50 @@ +@@ -2758,16 +2926,50 @@ rts ; 1b80 -> 1b82 -> 15cd r s=fb 8$: inc object1080_onscreen_clipped - 0x10,x ; 1b3b,1b41,1b47,1b4d -> 1b83 -> 1b86 r x=14..77 lda object1080_onscreen_shape_ptr_lo - 0x10,x ; 1b83 -> 1b86 -> 1b89 r x=14..77 @@ -572,7 +577,7 @@ 10$: lda *draw_y ; 1ba0,1bbf -> 1ba2 -> 1ba4 r cmp *clip_y0 ; 1ba2 -> 1ba4 -> 1ba6 r a=11..d8 bcc 12$ ; 1ba4 -> 1ba6 -> 1ba8,1bbb r c=0..1 -@@ -2764,6 +2963,16 @@ +@@ -2777,6 +2979,16 @@ bcc 12$ ; 1bac -> 1bae -> 1bb0,1bbb r c=0..1 cpy *clip_x1 ; 1bae -> 1bb0 -> 1bb2 r y=6c..a4 bcs 12$ ; 1bb0 -> 1bb2 -> 1bb4,1bbb r c=0..1 @@ -589,7 +594,7 @@ .db 0xbd ; 1bb2 -> 1bb4 -> 1bb7 r "lda 0x6fab,x" x=00..39 11$: .dw 0x6fab ; 1bb5 rw ora (*video_line_ptr),y ; 1bb4 -> 1bb7 -> 1bb9 r y=6c..93 -@@ -2777,6 +2986,7 @@ +@@ -2790,6 +3002,7 @@ cpy *draw_y1 ; 1bc3 -> 1bc5 -> 1bc7 r y=12..d9 bcc 9$ ; 1bc5 -> 1bc7 -> 1b96,1bc9 r c=0..1 ldx *x_save ; 1bc7 -> 1bc9 -> 1bcb r @@ -597,7 +602,7 @@ rts ; 1bc9 -> 1bcb -> 15cd r s=fb erase_pixel_object: lda #0x00 ; 1c12 -> 1bcc -> 1bce r -@@ -2808,12 +3018,15 @@ +@@ -2821,12 +3034,15 @@ eor #0xff ; 1c03 -> 1c06 -> 1c08 r and (*video_line_ptr),y ; 1c06 -> 1c08 -> 1c0a r y=6d..93,02 sta (*video_line_ptr),y ; 1c08 -> 1c0a -> 1c0c r y=6d..93,02 @@ -613,7 +618,7 @@ lda #0x00 ; 1c12 -> 1c14 -> 1c16 r sta object1080_onscreen - 0x10,x ; 1c14 -> 1c16 -> 1c19 r x=14..77 lda object1080_onscreen_x0 - 0x10,x ; 1c16 -> 1c19 -> 1c1c r x=14..77 -@@ -2828,16 +3041,61 @@ +@@ -2841,16 +3057,61 @@ stx *x_save ; 1c2d -> 1c30 -> 1c32 r bne 3$ ; 1c30 -> 1c32 -> 1c34,1c6a r z=0..1 lda object1080_onscreen_shape_ptr_lo - 0x10,x ; 1c32 -> 1c34 -> 1c37 r x=14..77 @@ -675,7 +680,7 @@ 1$: .db 0xbd ; 1c4e,1c5d -> 1c50 -> 1c53 r "lda 0x6f93,x" x=00..39 2$: .dw 0x6f93 ; 1c51 rw eor #0xff ; 1c50 -> 1c53 -> 1c55 r -@@ -2854,16 +3112,51 @@ +@@ -2867,16 +3128,51 @@ ldx *x_save ; 1c65 -> 1c67 -> 1c69 r rts ; 1c67 -> 1c69 -> 1076,16a8 r s=f3..f9,02 3$: lda object1080_onscreen_shape_ptr_lo - 0x10,x ; 1c32 -> 1c6a -> 1c6d r x=14..77 @@ -729,7 +734,7 @@ 5$: lda *draw_y ; 1c84,1ca5 -> 1c86 -> 1c88 r cmp *clip_y0 ; 1c86 -> 1c88 -> 1c8a r a=11..d8 bcc 7$ ; 1c88 -> 1c8a -> 1c8c,1ca1 r c=0..1 -@@ -2873,6 +3166,17 @@ +@@ -2886,6 +3182,17 @@ bcc 7$ ; 1c90 -> 1c92 -> 1c94,1ca1 r c=0..1 cpy *clip_x1 ; 1c92 -> 1c94 -> 1c96 r y=6c..a4 bcs 7$ ; 1c94 -> 1c96 -> 1c98,1ca1 r c=0..1 @@ -747,7 +752,7 @@ .db 0xbd ; 1c96 -> 1c98 -> 1c9b r "lda 0x6fab,x" x=00..39 6$: .dw 0x6fab ; 1c99 rw eor #0xff ; 1c98 -> 1c9b -> 1c9d r -@@ -2892,9 +3196,24 @@ +@@ -2905,9 +3212,24 @@ stx *x_save ; 1db0 -> 1cb2 -> 1cb4 r tay ; 1cb2 -> 1cb4 -> 1cb5 r lda shape_data_ptr_lo,y ; 1cb4 -> 1cb5 -> 1cb8 r y=16..ff @@ -772,7 +777,7 @@ lda shape_width_bytes,y ; 1cbe -> 1cc1 -> 1cc4 r y=16..ff clc ; 1cc1 -> 1cc4 -> 1cc5 r adc *draw_x0 ; 1cc4 -> 1cc5 -> 1cc7 r c=0 d=0 -@@ -2902,6 +3221,11 @@ +@@ -2915,6 +3237,11 @@ lda *draw_x0 ; 1cc7 -> 1cc9 -> 1ccb r lsr a ; 1cc9 -> 1ccb -> 1ccc r bcc 0$ ; 1ccb -> 1ccc -> 1cce,1cd4 r c=0..1 @@ -784,7 +789,7 @@ lda *draw_misc_mask ; 1ccc -> 1cce -> 1cd0 r eor *draw_misc_mask_xor ; 1cce -> 1cd0 -> 1cd2 r sta *draw_misc_mask ; 1cd0 -> 1cd2 -> 1cd4 r -@@ -2917,9 +3241,56 @@ +@@ -2930,9 +3257,56 @@ lda video_line_table_hi,y ; 1ce5 -> 1ce7 -> 1cea r y=00..bc adc #0x00 ; 1ce7 -> 1cea -> 1cec r c=0..1 d=0 sta *video_line_ptr + 1 ; 1cea -> 1cec -> 1cee r @@ -841,7 +846,7 @@ 2$: lda *draw_y ; 1cf2,1d0f -> 1cf4 -> 1cf6 r cmp #0xc0 ; 1cf4 -> 1cf6 -> 1cf8 r a=00..bc bcs 4$ ; 1cf6 -> 1cf8 -> 1cfa r c=0 -@@ -2939,7 +3310,12 @@ +@@ -2952,7 +3326,12 @@ inc *draw_y ; 1d0f -> 1d11 -> 1d13 r ldy *draw_y ; 1d11 -> 1d13 -> 1d15 r cpy *draw_y1 ; 1d13 -> 1d15 -> 1d17 r y=01..bd @@ -854,7 +859,7 @@ ldx *x_save ; 1d17 -> 1d19 -> 1d1b r rts ; 1d19 -> 1d1b -> 1db3 r s=ec..f5 draw_misc_from_table: -@@ -2952,7 +3328,7 @@ +@@ -2965,7 +3344,7 @@ asl a ; 1d23 -> 1d24 -> 1d25 r sta *draw_misc_ptr ; 1d24 -> 1d25 -> 1d27 r lda #0x00 ; 1d25 -> 1d27 -> 1d29 r @@ -863,7 +868,7 @@ sta *draw_misc_ptr + 1 ; 1d29 -> 1d2b -> 1d2d r lda *half_dimension ; 1d2b -> 1d2d -> 1d2f r lsr a ; 1d2d -> 1d2f -> 1d30 r -@@ -2961,10 +3337,20 @@ +@@ -2974,10 +3353,20 @@ lsr a ; 1d31 -> 1d32 -> 1d33 r lsr a ; 1d32 -> 1d33 -> 1d34 r tay ; 1d33 -> 1d34 -> 1d35 r @@ -884,7 +889,7 @@ lda *half_dimension ; 1d3d -> 1d3f -> 1d41 r and #0x1f ; 1d3f -> 1d41 -> 1d43 r cmp #0x08 ; 1d41 -> 1d43 -> 1d45 r a=00..1f -@@ -2982,6 +3368,14 @@ +@@ -2995,6 +3384,14 @@ iny ; 1d57 -> 1d59 -> 1d5a r 1$: lda (*draw_misc_ptr),y ; 1d59,1d69 -> 1d5a -> 1d5c r y=03..0c beq 2$ ; 1d5a -> 1d5c -> 1d5e,1d61 r z=0..1 @@ -899,7 +904,7 @@ jsr do_draw_misc ; 1d5c -> 1d5e -> 1da6 r s=f3..f9,02 2$: iny ; 1d5c,1db5 -> 1d61 -> 1d62 r cpy #0x10 ; 1d61 -> 1d62 -> 1d64 r y=04..0d -@@ -3037,6 +3431,84 @@ +@@ -3050,6 +3447,84 @@ ldy *draw_misc_y_save ; 1d1b -> 1db3 -> 1db5 r rts_1db5: rts ; 1da1,1db3 -> 1db5 -> 1076,1d61,1d7d,1d82,1d87 r s=ee..f7 @@ -984,7 +989,7 @@ draw_misc_mask_table: .db 0xff ; 1db6 r .db 0x00 ; 1db7 r -@@ -3047,14 +3519,15 @@ +@@ -3060,15 +3535,17 @@ .db 0xd5 ; 1dbc r .db 0xff ; 1dbd r draw_misc_mask_xor_table: @@ -1006,9 +1011,11 @@ + .db 0xff ^ 0xff ;0x00 ; 1dc5 r +.endif ++; for DHGR the following code will be moved to the end to make room .area text2 -@@ -3366,6 +3839,15 @@ + do_player_input: +@@ -3381,6 +3858,15 @@ .area data2 @@ -1024,7 +1031,7 @@ shape_data_ptr_lo: .db