ram.asm initial commit. Replaced all address defines with labels

Value defines styled without quotes, # moved to load/store/cmp site
Added registers.asm (copied from spannerisms JP disassembly)
Added a bunch of length annotations
Deleted old or trivial commented out code
Deleted: ganonfixes.asm, map.asm, seedtag.asm
Replaced obsolete credits.asm with creditsnew.asm
Moved scratch space at $7F5020-3F to mirrored WRAM (7E1E70-8F)
Moved clock RAM to mirrored WRAM (7E1E90-9F)
dialog.asm: FreeDungeonItemNotice preserves callee-preserved scratch RAM
Toast buffer moved to mirrored WRAM (7E1E0E-0F)
servicerequest.asm: long store to $012E converted to word length store
This commit is contained in:
cassidoxa
2022-11-05 00:50:25 -04:00
parent cafb0908a0
commit 43f753b517
72 changed files with 7706 additions and 7305 deletions

View File

@@ -6,13 +6,13 @@
; $60 - $7E - Reserved
; $7F - RX Status
; $80 - $EF - TX Buffer
; $E0 - $FE - Reserved
; $F0 - $FE - Reserved
; $FF - TX Status
;--------------------------------------------------------------------------------
; Status Codes
; #$00 - Idle
; #$01 - Ready to Read
; #$FF - Busy
; $00 - Idle
; $01 - Ready to Read
; $FF - Busy
;--------------------------------------------------------------------------------
; Service Indexes
; 0x00 - 0x04 - chests
@@ -21,80 +21,73 @@
; 0xF2 - tablet/pedestal
;--------------------------------------------------------------------------------
; Block Commands
!SCM_WAIT = "#$00"
!SCM_WAIT = $00
!SCM_SEEN = "#$01"
!SCM_SHOW = "#$02"
!SCM_GET = "#$03"
!SCM_GIVE = "#$04"
!SCM_PROMPT = "#$05"
!SCM_SEEN = $01
!SCM_SHOW = $02
!SCM_GET = $03
!SCM_GIVE = $04
!SCM_PROMPT = $05
!SCM_AREACHG = "#$10"
!SCM_DUNGEON = "#$11"
!SCM_DEATH = "#$12"
!SCM_SAVEQUIT = "#$13"
!SCM_FCREATE = "#$14"
!SCM_FLOAD = "#$15"
!SCM_FCDELETE = "#$16"
!SCM_SPAWN = "#$17"
!SCM_PAUSE = "#$18"
!SCM_AREACHG = $10
!SCM_DUNGEON = $11
!SCM_DEATH = $12
!SCM_SAVEQUIT = $13
!SCM_FCREATE = $14
!SCM_FLOAD = $15
!SCM_FCDELETE = $16
!SCM_SPAWN = $17
!SCM_PAUSE = $18
!SCM_STALL = "#$70"
!SCM_RESUME = "#$71"
!SCM_STALL = $70
!SCM_RESUME = $71
!SCM_VERSION = "#$80"
; ;--------------------------------------------------------------------------------
!RX_BUFFER = "$7F5300"
!RX_STATUS = "$7F537F"
;ServiceSequenceRx = $7EF4A0
!TX_BUFFER = "$7F5380"
!TX_STATUS = "$7F53FF"
;ServiceSequenceTx = $7EF4A0
!SCM_VERSION = $80
;--------------------------------------------------------------------------------
macro ServiceRequestVersion()
LDA !TX_STATUS : BEQ + : CLC : RTL : + ; return fail if we don't have the lock
LDA.b #$01 : STA !TX_BUFFER+8 ; version
LDA.b #$00 : STA !TX_BUFFER+9
STA !TX_BUFFER+10
STA !TX_BUFFER+11
LDA.b !SCM_VERSION : STA !TX_BUFFER
LDA #$01 : STA !TX_STATUS ; mark ready for reading
LDA.l TxStatus : BEQ + : CLC : RTL : + ; return fail if we don't have the lock
LDA.b #$01 : STA.l TxBuffer+8 ; version
LDA.b #$00 : STA.l TxBuffer+9
STA.l TxBuffer+10
STA.l TxBuffer+11
LDA.b #!SCM_VERSION : STA.l TxBuffer
LDA.b #$01 : STA.l TxStatus ; mark ready for reading
SEC ; mark request as successful
RTL
endmacro
;--------------------------------------------------------------------------------
macro ServiceRequestChest(type)
LDA !TX_STATUS : BEQ + : CLC : RTL : + ; return fail if we don't have the lock
LDA $1B : STA !TX_BUFFER+8 ; indoor/outdoor
LDA.l TxStatus : BEQ + : CLC : RTL : + ; return fail if we don't have the lock
LDA.b $1B : STA.l TxBuffer+8 ; indoor/outdoor
BEQ +
LDA $A0 : STA !TX_BUFFER+9 ; roomid low
LDA $A1 : STA !TX_BUFFER+10 ; roomid high
LDA.b $A0 : STA.l TxBuffer+9 ; roomid low
LDA.b $A1 : STA.l TxBuffer+10 ; roomid high
BRA ++
+
LDA $040A : STA !TX_BUFFER+9 ; area id
LDA.b #$00 : STA !TX_BUFFER+10 ; protocol defines this as a ushort
LDA.w $040A : STA.l TxBuffer+9 ; area id
LDA.b #$00 : STA.l TxBuffer+10 ; protocol defines this as a ushort
++
LDA $76 : !SUB #$58 : STA !TX_BUFFER+11 ; object index (type 2 only)
LDA <type> : STA !TX_BUFFER ; item get
LDA #$01 : STA !TX_STATUS ; mark ready for reading
LDA.b $76 : !SUB #$58 : STA.l TxBuffer+11 ; object index (type 2 only)
LDA.b #<type> : STA.l TxBuffer ; item get
LDA.b #$01 : STA.l TxStatus ; mark ready for reading
SEC ; mark request as successful
RTL
endmacro
;--------------------------------------------------------------------------------
macro ServiceRequest(type,index)
LDA !TX_STATUS : BEQ + : CLC : RTL : + ; return fail if we don't have the lock
LDA $1B : STA !TX_BUFFER+8 ; indoor/outdoor
LDA.l TxStatus : BEQ + : CLC : RTL : + ; return fail if we don't have the lock
LDA.b $1B : STA.l TxBuffer+8 ; indoor/outdoor
BEQ +
LDA $A0 : STA !TX_BUFFER+9 ; roomid low
LDA $A1 : STA !TX_BUFFER+10 ; roomid high
LDA.b $A0 : STA.l TxBuffer+9 ; roomid low
LDA.b $A1 : STA.l TxBuffer+10 ; roomid high
BRA ++
+
LDA $040A : STA !TX_BUFFER+9 ; area id
LDA.b #$00 : STA !TX_BUFFER+10 ; protocol defines this as a ushort
LDA.w $040A : STA.l TxBuffer+9 ; area id
LDA.b #$00 : STA.l TxBuffer+10 ; protocol defines this as a ushort
++
LDA <index> : STA !TX_BUFFER+11 ; object index (type 2 only)
LDA <type> : STA !TX_BUFFER ; item get
LDA #$01 : STA !TX_STATUS ; mark ready for reading
LDA.b #<index> : STA.l TxBuffer+11 ; object index (type 2 only)
LDA.b #<type> : STA.l TxBuffer ; item get
LDA.b #$01 : STA.l TxStatus ; mark ready for reading
SEC ; mark request as successful
RTL
endmacro
@@ -102,55 +95,55 @@ endmacro
PollService:
PHP
SEP #$20 ; set 8-bit accumulator
LDA !RX_STATUS : DEC : BEQ + : PLP : CLC : RTL : + ; return fail if there's nothing to read
LDA #$FF : STA !RX_STATUS ; stop calls from recursing in
LDA !RX_BUFFER : CMP.b !SCM_GIVE : BNE + ; give item
PHY : LDA.l !RX_BUFFER+8 : TAY
LDA.l !RX_BUFFER+9 : BNE ++
LDA.l RxStatus : DEC : BEQ + : PLP : CLC : RTL : + ; return fail if there's nothing to read
LDA.b #$FF : STA.l RxStatus ; stop calls from recursing in
LDA.l RxBuffer : CMP.b #!SCM_GIVE : BNE + ; give item
PHY : LDA.l RxBuffer+8 : TAY
LDA.l RxBuffer+9 : BNE ++
JSL.l Link_ReceiveItem ; do something else
PLY : BRA .done
++
JSL.l Link_ReceiveItem
PLY : BRA .done
+ : CMP.b !SCM_SHOW : BNE + ; show item
+ : CMP.b #!SCM_SHOW : BNE + ; show item
; you could check here if you're on the right screen, etc
LDA.l !RX_BUFFER+12 : JSL.l PrepDynamicTile ; we could properly process the whole message but we're not going to
LDA.l RxBuffer+12 : JSL.l PrepDynamicTile ; we could properly process the whole message but we're not going to
BRA .done
+ : CMP.b !SCM_PROMPT : BNE + ; item prompt
LDA.l !RX_BUFFER+8 : TAX
LDA.l !RX_BUFFER+9 : STA $7E012E, X ; set sound effect, could possibly make this STA not-long
+ : CMP.b #!SCM_PROMPT : BNE + ; item prompt
LDA.l RxBuffer+8 : TAX
LDA.l RxBuffer+9 : STA.w $012E, X ; set sound effect
REP #$30 ; set 16-bit accumulator and index registers
LDA !RX_BUFFER+10 : TAX
LDA !RX_BUFFER+12
LDA.l RxBuffer+10 : TAX
LDA.l RxBuffer+12
JSL.l DoToast
SEP #$30 ; set 8-bit accumulator and index registers
+ : CMP.b !SCM_VERSION : BNE + ; version
+ : CMP.b #!SCM_VERSION : BNE + ; version
%ServiceRequestVersion()
+
.done
LDA #$00 : STA !RX_STATUS ; release lock
LDA.l #$00 : STA.l RxStatus ; release lock
PLP
SEC ; mark request as successful
RTL
;--------------------------------------------------------------------------------
ItemVisualServiceRequest_F0:
%ServiceRequest(!SCM_SEEN, #$F0)
%ServiceRequest(!SCM_SEEN, $F0)
;--------------------------------------------------------------------------------
ItemVisualServiceRequest_F1:
%ServiceRequest(!SCM_SEEN, #$F1)
%ServiceRequest(!SCM_SEEN, $F1)
;--------------------------------------------------------------------------------
ItemVisualServiceRequest_F2:
%ServiceRequest(!SCM_SEEN, #$F2)
%ServiceRequest(!SCM_SEEN, $F2)
;--------------------------------------------------------------------------------
ChestItemServiceRequest:
%ServiceRequestChest(!SCM_GET)
;--------------------------------------------------------------------------------
ItemGetServiceRequest_F0:
%ServiceRequest(!SCM_GET, #$F0)
%ServiceRequest(!SCM_GET, $F0)
;--------------------------------------------------------------------------------
ItemGetServiceRequest_F1:
%ServiceRequest(!SCM_GET, #$F1)
%ServiceRequest(!SCM_GET, $F1)
;--------------------------------------------------------------------------------
ItemGetServiceRequest_F2:
%ServiceRequest(!SCM_GET, #$F2)
%ServiceRequest(!SCM_GET, $F2)
;--------------------------------------------------------------------------------