This commit is contained in:
Kat
2020-02-04 19:40:33 -05:00
parent f95512e089
commit c1628dcb0e
3 changed files with 41 additions and 31 deletions

View File

@@ -18,6 +18,7 @@ OnDrawHud:
JSL.l DrawChallengeTimer ; this has to come before NewDrawHud because the timer overwrites the compass counter
JSL.l NewDrawHud
JSL.l SwapSpriteIfNecissary
JSL.l PollService
JML.l ReturnFromOnDrawHud
;--------------------------------------------------------------------------------
;OnDungeonEntrance:

View File

@@ -11,24 +11,25 @@
;--------------------------------------------------------------------------------
; Status Codes
; #$00 - Idle
; #$01 - Local Read/Write
; #$02 - Ready for External Read/Write
; #$01 - Ready to Read
; #$FF - Busy
;--------------------------------------------------------------------------------
; Block Commands
!SCM_WAIT = "#$00"
!SCM_SEEN = "#$01"
!SCM_GET = "#$02"
!SCM_PROMPT = "#$03"
!SCM_AREACHG = "#$04"
!SCM_DUNGEON = "#$05"
!SCM_DEATH = "#$06"
!SCM_SAVEQUIT = "#$07"
!SCM_FCREATE = "#$08"
!SCM_FLOAD = "#$09"
!SCM_FCDELETE = "#$0A"
!SCM_SPAWN = "#$0B"
!SCM_PAUSE = "#$0C"
!SCM_GIVE = "#$03"
!SCM_PROMPT = "#$04"
!SCM_AREACHG = "#$05"
!SCM_DUNGEON = "#$06"
!SCM_DEATH = "#$07"
!SCM_SAVEQUIT = "#$08"
!SCM_FCREATE = "#$09"
!SCM_FLOAD = "#$0A"
!SCM_FCDELETE = "#$0B"
!SCM_SPAWN = "#$0C"
!SCM_PAUSE = "#$0D"
!SCM_STALL = "#$7E"
!SCM_RESUME = "#$7F"
@@ -41,11 +42,19 @@
!TX_SEQUENCE = "$7EF4A0"
;--------------------------------------------------------------------------------
PollService:
LDA !RX_STATUS : BEQ + : SEC : RTL : + ; return fail if we don't have the lock
LDA #$01 : STA !RX_STATUS ; mark busy
LDA !RX_BUFFER+1 : STA !RX_SEQUENCE ; mark this as handled
LDA !RX_BUFFER+2 : STA !RX_SEQUENCE+1
LDA !RX_BUFFER : CMP.b #03 : BNE +
PHP
SEP #$20 ; set 8-bit accumulator
LDA !RX_STATUS : DEC : BEQ + : PLP : SEC : 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 +
PHY : LDA.l !RX_BUFFER+8 : TAY
LDA.l !RX_BUFFER+9 : BNE ++
JSL.l Link_ReceiveItem ; do something else
PLY : BRA .done
++
JSL.l Link_ReceiveItem
PLY : BRA .done
+ : CMP.b !SCM_PROMPT : BNE +
LDA.l !RX_BUFFER+8 : TAX
LDA.l !RX_BUFFER+9 : STA $7E012E, X ; set sound effect, could possibly make this STA not-long
REP #$30 ; set 16-bit accumulator and index registers
@@ -54,27 +63,27 @@ PollService:
JSL.l DoToast
SEP #$30 ; set 8-bit accumulator and index registers
+
.done
LDA #$00 : STA !RX_STATUS ; release lock
PLP
CLC ; mark request as successful
RTL
;--------------------------------------------------------------------------------
macro ServiceRequest(type)
LDA !TX_STATUS : BEQ + : SEC : RTL : + ; return fail if we don't have the lock
LDA #$01 : STA !TX_STATUS ; mark busy
LDA $7B : STA !TX_BUFFER+1 ; world
LDA $1B : STA !TX_BUFFER+2 ; indoor/outdoor
LDA $A0 : STA !TX_BUFFER+3 ; roomid low
LDA $A1 : STA !TX_BUFFER+4 ; roomid high
LDA $76 : STA !TX_BUFFER+5 ; object index (type 2 only)
LDA $1B : STA !TX_BUFFER+8 ; indoor/outdoor
LDA $A0 : STA !TX_BUFFER+9 ; roomid low
LDA $A1 : STA !TX_BUFFER+10 ; roomid high
LDA $76 : STA !TX_BUFFER+11 ; object index (type 2 only)
LDA <type> : STA !TX_BUFFER ; item get
LDA #$00 : STA !TX_STATUS ; release lock
LDA #$01 : STA !TX_STATUS ; mark ready for reading
CLC ; mark request as successful
RTL
endmacro
;--------------------------------------------------------------------------------
ItemVisualServiceRequest:
%ServiceRequest(#$01)
%ServiceRequest(!SCM_SEEN)
;--------------------------------------------------------------------------------
ItemGetServiceRequest:
%ServiceRequest(#$02)
%ServiceRequest(!SCM_GET)
;--------------------------------------------------------------------------------