Skip to content

Commit

Permalink
Add more splits of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hansbonini committed Jul 9, 2024
1 parent 7fdefe7 commit 3f0f41f
Show file tree
Hide file tree
Showing 22 changed files with 475 additions and 478 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build/*
gfx/nemesis/*.smd
gfx/segard/*.smd
rom/*
smps/*
674 changes: 217 additions & 457 deletions Altered Beast.asm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/decomp/segard.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
segard_decomp: ; CODE XREF: ROM:00008C08 p
; ROM:00008C20 p ...
lea (unk_FFF400).w,a4
lea (SEGARD_DECOMP_BUFFER).w,a4
lea (VDP_DATA).l,a5
loc_46FE: ; CODE XREF: segard_decomp+64 j
moveq #0,d0
Expand Down
12 changes: 12 additions & 0 deletions includes/helpers/clear_vsram.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
clear_vsram: ; CODE XREF: vdp_setup+38 p
move.l #$40000010,d7 ; DO_WRITE_TO_VSRAM_AT_$0000_ADDR
; DO_OPERATION_WITHOUT_DMA
moveq #$28,d6 ; '('
loc_4682: ; CODE XREF: vdp_setup+54 j
moveq #0,d5
move.l d7,(VDP_CTRL).l
loc_468A: ; CODE XREF: clear_vsram+16 j
move.w d5,(VDP_DATA).l
dbf d6,loc_468A
rts
; End of function clear_vsram
19 changes: 19 additions & 0 deletions includes/helpers/draw_text.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
draw_text: ; CODE XREF: ROM:0000BC00 p
; ROM:0000BF30 p ...
move.w (word_FFB106).w,d6
; End of function draw_text
sub_47F4: ; CODE XREF: ROM:0000BC0C p
move.l (a6)+,d7
loc_47F6: ; CODE XREF: ROM:0000C0A6 p
; sub_C1EC+22 j
; DATA XREF: ...
move.l d7,(VDP_CTRL).l
loc_47FC: ; CODE XREF: sub_47F4+12 j
move.b (a6)+,d6
beq.s locret_4808
move.w d6,(VDP_DATA).l
bra.s loc_47FC
; ---------------------------------------------------------------------------
locret_4808: ; CODE XREF: sub_47F4+A j
rts
; End of function sub_47F4
7 changes: 7 additions & 0 deletions includes/helpers/init_joypad.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
init_joypad: ; CODE XREF: Reset+B0 p
moveq #$40,d0 ; '@'
move.b d0,(IO_CT1_CTRL+1).l
move.b d0,(IO_CT2_CTRL+1).l
move.b d0,(IO_EXT_CTRL+1).l
rts
; End of function init_joypad
42 changes: 42 additions & 0 deletions includes/helpers/init_z80.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
loc_4924: ; CODE XREF: reset_z80+3A j
btst #0,(IO_Z80BUS).l
bne.s loc_4924
transfer_sounddriver_to_z80: ; CODE XREF: reset_z80+28 j
; play_bgm+34 j
clr.l (dword_FFFE1A).w
clr.w (word_FFFE26).w
lea (z80snd_driver).l,a5
lea (Z80_RAM).l,a6
move.w #$1CB,d0
loc_4946: ; CODE XREF: reset_z80+74 j
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
dbf d0,loc_4946
lea (byte_A01D03).l,a6
lea (dword_FFFE20).w,a5
move.b (a5),(a6)+
move.b (a5),(a6)+
loc_4978: ; CODE XREF: play_bgm+B2 j
move.w #0,(IO_Z80RES).l ; Disable the Z80 reset
move.w #0,(IO_Z80BUS).l ; Give the Z80 the bus back
moveq #9,d0
loc_498A: ; CODE XREF: reset_z80+9A j
nop
dbf d0,loc_498A
move.w #$100,(IO_Z80RES).l ; Reset the Z80
rts
; End of function reset_z80
50 changes: 50 additions & 0 deletions includes/helpers/load_dacdriver_to_z80.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
load_dacdriver_to_z80: ; CODE XREF: play_bgm+6 j
bclr #7,(dword_FFFE1A).w
move.w (dword_FFFE1A).w,d0
add.w d0,d0
add.w (dword_FFFE1A).w,d0
add.w d0,d0
lea loc_4A46+4(pc,d0.w),a5
move.w (a5)+,d0
movea.l (a5),a5
move.w (word_FFFE1E).w,d7
move.w #$100,(IO_Z80BUS).l
loc_4A12: ; CODE XREF: play_bgm+80 j
btst #0,(IO_Z80BUS).l
bne.s loc_4A12
lea (Z80_RAM).l,a6
loc_4A22: ; CODE XREF: play_bgm+A8 j
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
move.b (a5)+,(a6)+
dbf d0,loc_4A22
loc_4A46: ; DATA XREF: play_bgm+64 o
move.b d7,(byte_A0017F).l
bra.w loc_4978
; End of function play_bgm
; ---------------------------------------------------------------------------
dacdriver_list: dc.w $1C4 ; entries.size
dc.l dacdriver_1 ; entries.offset
dc.w $1E8 ; entries.size
dc.l dacdriver_2 ; entries.offset
dc.w $1F6 ; entries.size
dc.l dacdriver_3 ; entries.offset
dc.w $1F8 ; entries.size
dc.l dacdriver_4 ; entries.offset
dc.w $1D3 ; entries.size
dc.l dacdriver_5 ; entries.offset
dc.w $1F8 ; entries.size
dc.l dacdriver_6 ; entries.offset
File renamed without changes.
19 changes: 19 additions & 0 deletions includes/helpers/play_bgm.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
play_bgm: ; CODE XREF: VBLANK+6E p
tst.w (dword_FFFE1A).w
beq.s locret_49DA
bmi.s load_dacdriver_to_z80
move.b (dword_FFFE20).w,d0
andi.w #$7F,d0
cmpi.w #$F,d0
bhi.s loc_49B6
move.b bgm_list(pc,d0.w),(dword_FFFE20).w
loc_49B6: ; CODE XREF: play_bgm+14 j
move.w #$100,(IO_Z80BUS).l ; Send the Z80 a bus request
loc_49BE: ; CODE XREF: play_bgm+2C j
btst #0,(IO_Z80BUS).l
bne.s loc_49BE
tst.b (byte_A0017F).l
beq.w transfer_sounddriver_to_z80
move.w #0,(IO_Z80BUS).l ; Give the Z80 the bus back
locret_49DA: ; CODE XREF: play_bgm+4 j
rts
34 changes: 34 additions & 0 deletions includes/helpers/read_joypad.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
read_joypad: ; CODE XREF: VBLANK:loc_A7BC p
lea (JOYPAD_STATE).w,a0
lea ((IO_CT1_DATA+1)).l,a1
bsr.w sub_484E
lea ((IO_CT2_DATA+1)).l,a1
; End of function read_joypad
sub_484E: ; CODE XREF: read_joypad+A p
move.b #0,(a1)
nop
nop
nop
move.b (a1),d1
nop
nop
nop
move.b #$40,(a1) ; '@'
asl.w #2,d1
move.w d1,d2
move.b (a1),d0
andi.w #$30,d2 ; '0'
beq.w loc_4876
move.w #$FF,d1
loc_4876: ; CODE XREF: sub_484E+20 j
andi.w #$3F,d0 ; '?'
andi.w #$C0,d1
or.w d1,d0
not.w d0
eor.b d0,(a0)
move.b (a0),d1
move.b d0,(a0)+
and.w d1,d0
move.b d0,(a0)+
rts
; End of function sub_484E
13 changes: 13 additions & 0 deletions includes/helpers/reset_z80.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
reset_z80: ; CODE XREF: Reset+AA p
; ROM:screen_segalogo p ...
move.l #$80000000,(dword_FFFE20).w
loc_48FA: ; CODE XREF: ROM:0000BAE4 p
; DATA XREF: ROM:0000BAE4 o
move.w #$100,(IO_Z80BUS).l ; Send the Z80 a bus request
move.w #0,(IO_Z80RES).l ; Disable the Z80 reset
moveq #9,d0
loc_490C: ; CODE XREF: reset_z80+1C j
nop
dbf d0,loc_490C
move.w #$100,(IO_Z80RES).l ; Reset the Z80
bra.s transfer_sounddriver_to_z80
14 changes: 14 additions & 0 deletions includes/helpers/write_z80ram_1d03.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
write_z80ram_1d03: ; CODE XREF: ROM:00004F52 j
; ROM:00008D12 j ...
tst.w (dword_FFFE1A).w
bne.s loc_4AEC
move.w #$100,(IO_Z80BUS).l
loc_4AD4: ; CODE XREF: write_z80ram_1d03+16 j
btst #0,(IO_Z80BUS).l
bne.s loc_4AD4
move.b d7,(byte_A01D03).l
move.w #0,(IO_Z80BUS).l
loc_4AEC: ; CODE XREF: write_z80ram_1d03+4 j
move.b d7,(dword_FFFE20).w
rts
; End of function write_z80ram_1d03
13 changes: 13 additions & 0 deletions includes/helpers/write_z80ram_1d05.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
write_z80ram_1d05: ; CODE XREF: ROM:00000382 p
; ROM:0000039C p ...
tst.l (dword_FFFE1A).w
bne.s locret_4B40
move.w #$100,(IO_Z80BUS).l
loc_4B28: ; CODE XREF: write_z80ram_1d05+16 j
btst #0,(IO_Z80BUS).l
bne.s loc_4B28
move.b d7,(byte_A01D05).l
move.w #0,(IO_Z80BUS).l
locret_4B40: ; CODE XREF: write_z80ram_1d05+4 j
rts
; End of function write_z80ram_1d05
13 changes: 13 additions & 0 deletions includes/helpers/write_z80ram_1d06.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
write_z80ram_1d06: ; CODE XREF: ROM:00000F82 p
; ROM:00004D36 p ...
tst.l (dword_FFFE1A).w
bne.s locret_4B18
move.w #$100,(IO_Z80BUS).l
loc_4B00: ; CODE XREF: write_z80ram_1d06+16 j
btst #0,(IO_Z80BUS).l
bne.s loc_4B00
move.b d7,(byte_A01D06).l
move.w #0,(IO_Z80BUS).l
locret_4B18: ; CODE XREF: write_z80ram_1d06+4 j
rts
; End of function write_z80ram_1d06
2 changes: 1 addition & 1 deletion includes/interrupts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ off_60: dc.l Reserv3F
dc.l IRQ5
dc.l VBLANK
dc.l IRQ7
dc.l Trap15
off_80: dc.l Trap15
dc.l Trap15
dc.l Trap15
off_8C: dc.l Trap15
Expand Down
12 changes: 6 additions & 6 deletions includes/interrupts/reset.asm
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ loc_A632: ; CODE XREF: Reset+44 j
loc_A648: ; CODE XREF: Reset+76 j
move.l d7,(a6)+
dbf d6,loc_A648
move.w #CREDITS_3_LIVES_3,(ram_lives).w
lea (ram_beasts).w,a6
move.w #CREDITS_3_LIVES_3,(LIVES).w
lea (BEAST).w,a6
move.l #3,(a6)+
move.l #$20001,(a6)+
move.w #0,(a6)+
loc_A668: ; CODE XREF: Reset+66 j
move.l #$A76A,(dword_FFB100).w
move.l #loc_A76A,(dword_FFB100).w
lea (unk_FFB000).w,a0
move.w #$F7F,d0
loc_A678: ; CODE XREF: Reset+A6 j
clr.l (a0)+
dbf d0,loc_A678
jsr (sub_48F2).l
bsr.w sub_4824
jsr (reset_z80).l
bsr.w init_joypad
bsr.w sub_44FC
move.l #$40000000,d7 ; DO_WRITE_TO_VRAM_AT_$0000_ADDR
; DO_OPERATION_WITHOUT_DMA
Expand All @@ -67,7 +67,7 @@ loc_A69E: ; CODE XREF: Reset+114 j
moveq #0,d0
btst #1,(byte_FFB104).w
bne.s loc_A6BA
move.w (word_FFB144).w,d0
move.w (JOYPAD_STATE).w,d0
loc_A6BA: ; CODE XREF: Reset+E0 j
btst #2,(byte_FFB104).w
bne.s loc_A6C6
Expand Down
2 changes: 1 addition & 1 deletion includes/interrupts/trap15.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Trap15: ; CODE XREF: Trap15 j
; DATA XREF: ROM:00000080 o ...
; DATA XREF: ROM:off_80 o ...
bra.s Trap15
; End of function Trap15
4 changes: 2 additions & 2 deletions includes/interrupts/vblank.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ loc_A7AA: ; CODE XREF: VBLANK+18 j
tst.b (byte_FFB154).w
beq.s loc_A7C0
loc_A7BC: ; CODE XREF: VBLANK+44 j
bsr.w sub_483A
bsr.w read_joypad
loc_A7C0: ; CODE XREF: VBLANK+4A j
btst #1,(byte_FFB154).w
beq.s loc_A7DA
Expand All @@ -34,7 +34,7 @@ loc_A7C0: ; CODE XREF: VBLANK+4A j
loc_A7DA: ; CODE XREF: VBLANK+56 j
; VBLANK+60 j
clr.b (byte_FFB154).w
jsr (sub_499A).l
jsr (play_bgm).l
movem.l (sp)+,d0-d7/a0-a6
locret_A7E8: ; CODE XREF: ROM:loc_A7EA j
rte
Expand Down
2 changes: 1 addition & 1 deletion includes/vdp_setup.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ loc_A842: ; CODE XREF: vdp_setup+E j
loc_A86E: ; CODE XREF: ROM:00009236 p
; ROM:00009852 p ...
bsr.w sub_45BE
bsr.w sub_467A
bsr.w clear_vsram
bsr.w sub_45CC
bsr.w sub_45EE
bsr.w sub_45F8
Expand Down
6 changes: 3 additions & 3 deletions src/equals.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ CREDITS_5_LIVES_2 equ $508
CREDITS_5_LIVES_3 equ $50C
CREDITS_5_LIVES_4 equ $510
CREDITS_5_LIVES_5 equ $514
NORMAL equ 0 ; XREF: RAM:ram_difficulty/s
NORMAL equ 0 ; XREF: RAM:DIFFICULTY/s
HARD equ 1
HARDEST equ 2 ; XREF: ROM:0000AB5C/s
STAGE_1 equ 0
STAGE_2 equ 1 ; XREF: RAM:ram_stage/s
STAGE_2 equ 1 ; XREF: RAM:STAGE/s
STAGE_3 equ 2
STAGE_4 equ 3
STAGE_5 equ 4
WOLF equ 0
TIGER equ 1 ; XREF: RAM:ram_beasts/s
TIGER equ 1 ; XREF: RAM:BEAST/s
BEAR equ 2
DRAGON equ 3 ; XREF: RAM:00FFFE0C/s
; ----------------------------------
Expand Down
12 changes: 6 additions & 6 deletions src/ram_addrs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dword_FFB128 equ $FFFFB128
word_FFB12C equ $FFFFB12C
word_FFB140 equ $FFFFB140
byte_FFB143 equ $FFFFB143
word_FFB144 equ $FFFFB144
JOYPAD_STATE equ $FFFFB144
word_FFB146 equ $FFFFB146
byte_FFB14A equ $FFFFB14A
word_FFB14C equ $FFFFB14C
Expand Down Expand Up @@ -154,14 +154,14 @@ unk_FFF000 equ $FFFFF000
unk_FFF038 equ $FFFFF038
unk_FFF200 equ $FFFFF200
unk_FFF214 equ $FFFFF214
unk_FFF400 equ $FFFFF400
SEGARD_DECOMP_BUFFER equ $FFFFF400
dword_FFFE00 equ $FFFFFE00
ram_difficulty equ $FFFFFE04
ram_lives equ $FFFFFE06
ram_beasts equ $FFFFFE08
DIFFICULTY equ $FFFFFE04
LIVES equ $FFFFFE06
BEAST equ $FFFFFE08
word_FFFE12 equ $FFFFFE12
word_FFFE14 equ $FFFFFE14
ram_stage equ $FFFFFE16
STAGE equ $FFFFFE16
byte_FFFE18 equ $FFFFFE18
dword_FFFE1A equ $FFFFFE1A
word_FFFE1E equ $FFFFFE1E
Expand Down

0 comments on commit 3f0f41f

Please sign in to comment.