Commit: 6717f121b534df0ef5aaaba79e9aad073575fd08 Parent: cd619dc84cc9a455b20503506c10857bb1a1efba Author: Vi Grey Date: 2019-08-01 07:31 UTC Summary: Fixed bottom line bug Added CHANGELOG.md, CREDITS.md, fixed bottom line bug, fixed message wrap bug, added r16m file of the current payload CHANGELOG.md | 20 +++++ CREDITS.md | 19 +++++ smb2-discord-payload.r16m | Bin 0 -> 132832 bytes src/smb2-discord-payload.asm | 368 +++++++++++++++++++++++++++++++++++++++---------------------------------------- 4 files changed, 223 insertions(+), 184 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..467fe6d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Change Log +All notable changes to this project will be documented in this file. + +## 1.0.1 - 2019-08-01 +### Added +- CHANGELOG.md file (this file) +- CREDITS.md file +- Version number in a comment in src/smb2-discord-payload.asm +- smb2-discord-payload.r16m file which utilizes the current version of this payload for TASBot + +### Changed +- Nametable switching code into its own subroutine + +### Fixed +- Bottom line clearing during y-scroll when chat text data extends to a new row and the chat text data ends with a newline character on the same frame. Fixes issue where the bottom line will drift into the chat text data. +- Chat text data clearing during y-scroll when chat text data extends to a new row and the chat text data ends with a newline character on the same frame. Fixes issue where old chat text data will wrap from the bottom over time. + +## 1.0.0 - 2019-07-27 +### Added +- Initial release diff --git a/CREDITS.md b/CREDITS.md new file mode 100644 index 0000000..9fa4ee2 --- /dev/null +++ b/CREDITS.md @@ -0,0 +1,19 @@ +## DwangoAC +- Giving me this opportunity in the first place to make something and have it presented at ESA 2019 (European Speedrunner Assembly) for the TASBot Showcase +- Accepting me into the TASBot community +- Putting up with last minute stress of getting this run to work in the first place + +## Ownasaurus +- Making the TAStm32 board - [https://github.com/Ownasaurus/TAStm32](https://github.com/Ownasaurus/TAStm32) +- Testing the payload and helping me debug issues before the run was presented +- Helping me find bugs that showed up during the presentation so I can work on fixes + +## TheMas3212 +- Creating the code necessary to get Discord messages sent to TASBot as controller inputs + +## Total +- Making the SMB2 TAS run with Arbitrary Code Execution - [https://github.com/tewtal/smb2-ace-tas](https://github.com/tewtal/smb2-ace-tas) +- Creating the initial working .r16m script for me to base my .r16m script on + +### Important Note +**If I forgot to credit you or credited you incorrectly, please contact me at [vi@vigrey.com](vi@vigrey.com) or [@ViGreyTech](https://twitter.com/ViGreyTech) on Twitter** diff --git a/smb2-discord-payload.r16m b/smb2-discord-payload.r16m new file mode 100644 index 0000000..7082a5e Binary files /dev/null and b/smb2-discord-payload.r16m differ diff --git a/src/smb2-discord-payload.asm b/src/smb2-discord-payload.asm index e263d41..621b03e 100644 --- a/src/smb2-discord-payload.asm +++ b/src/smb2-discord-payload.asm @@ -23,11 +23,14 @@ ; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ; SUCH DAMAGE. +; Version 1.0.1 + .enum $00BF addr dsb 2 .ende .enum $7F00 +Variables: drawbufferoffset dsb 1 drawbuffer dsb 100 cursorframes dsb 1 @@ -48,6 +51,8 @@ screen dsb 1 frames dsb 1 seconds dsb 1 + deleteoffset dsb 1 + nametableaddrtmp dsb 2 .ende CHARACTER_TABLE_LENGTH = 44 @@ -81,7 +86,7 @@ LIGHT = $00 DARK = $01 SCREEN_LOADING = $00 SCREEN_CHAT = $01 -SECONDS = 6 +SECONDS = 5 FPS = 60 .base $6170 @@ -105,7 +110,7 @@ InitializeRAM: ldx #$00 InitializeRAMLoop: lda #$00 - sta $7F00, x + sta Variables, x lda #$FE sta $0200, x inx @@ -203,14 +208,14 @@ Update: beq UpdateTitleScreenSecondsDone jmp UpdateDone UpdateTitleScreenSecondsDone: - lda #SCREEN_CHAT - sta nmi - sta screen - jsr Blank - jsr ClearScreen - jsr DrawChatScreen - jsr ResetScroll - jmp UpdateDone + lda #SCREEN_CHAT + sta nmi + sta screen + jsr Blank + jsr ClearScreen + jsr DrawChatScreen + jsr ResetScroll + jmp UpdateDone UpdateScreenChat: inc cursorframes lda cursorframes @@ -222,7 +227,9 @@ UpdateScreenChat: jsr SwapCursor CursorFramesNot60: lda nmi - bne UpdateCheckText + beq UpdateNMI0 + jmp UpdateCheckText +UpdateNMI0: ldx #$00 UpdateScreenChatControllerLoop: jsr LatchController @@ -230,6 +237,30 @@ UpdateScreenChatControllerLoop: inx cpx #12 bne UpdateScreenChatControllerLoop + ldy deleteoffset + cpy #$02 + bne UpdateScreenChatOddFrameContinue + lda textaddr + sta tmp + lda (textaddr + 1) + sta (tmp + 1) + sec + sbc #$20 + sta (nametableaddrtmp + 1) + lda textaddr + sbc #$00 + sta nametableaddrtmp + jsr UpdateNametable + lda nametableaddrtmp + sta textaddr + lda (nametableaddrtmp + 1) + sta (textaddr + 1) + jsr ClearInputLine + lda (tmp + 1) + sta (textaddr + 1) + lda tmp + sta textaddr + UpdateScreenChatOddFrameContinue: jsr ClearInputLine ldy drawbufferoffset lda #$FF @@ -246,12 +277,79 @@ UpdateScreenChatControllerLoop: jsr TranslateCharacters jsr DrawInputText jsr DrawLineBackground + ldy deleteoffset + cpy #$02 + bne UpdateScreenChatTextContinue + lda textaddr + sta tmp + lda (textaddr + 1) + sta (tmp + 1) + sec + sbc #$20 + sta (nametableaddrtmp + 1) + lda textaddr + sbc #$00 + sta nametableaddrtmp + jsr UpdateNametable + lda nametableaddrtmp + sta textaddr + lda (nametableaddrtmp + 1) + sta (textaddr + 1) + jsr ClearLineBackground + lda (tmp + 1) + sta (textaddr + 1) + lda tmp + sta textaddr + jmp UpdateScreenChatTextNotDoubleNewline + UpdateScreenChatTextContinue: + jsr ClearLineBackground + UpdateScreenChatTextNotDoubleNewline: ldy drawbufferoffset lda #$FF sta (drawbuffer), y UpdateDone: rts + +UpdateNametable: + lda nametableaddrtmp + cmp #$23 + bcc UpdateNametableDone + cmp #$25 + bcs UpdateNametable2 + cmp #$23 + bne UpdateNametable0ModifyAddr + lda (nametableaddrtmp + 1) + cmp #$C0 + bcc UpdateNametableDone +UpdateNametable0ModifyAddr: + lda (nametableaddrtmp + 1) + sec + sbc #$C0 + sta (nametableaddrtmp + 1) + lda nametableaddrtmp + adc #$04 + sta nametableaddrtmp + jmp UpdateNametableDone +UpdateNametable2: + cmp #$2B + bcc UpdateNametableDone + bne UpdateNametable2ModifyAddr + lda (nametableaddrtmp + 1) + cmp #$C0 + bcc UpdateNametableDone +UpdateNametable2ModifyAddr: + lda (nametableaddrtmp + 1) + sec + sbc #$C0 + sta (nametableaddrtmp + 1) + lda nametableaddrtmp + sbc #$0B + sta nametableaddrtmp +UpdateNametableDone: + rts + + LatchController: ldy #$01 sty CONTROLLER1 @@ -802,56 +900,28 @@ ClearInputLine: and #%11100000 clc adc #$E2 - sta (addrtmp + 1) + sta (nametableaddrtmp + 1) lda textaddr adc #$00 + sta nametableaddrtmp + jsr UpdateNametable + + lda (nametableaddrtmp + 1) + sta (addrtmp + 1) + lda nametableaddrtmp sta addrtmp -ClearInputLineCheckEndNT0: - cmp #$23 - bcc ClearInputLineStart - cmp #$25 - bcs ClearInputLineCheckEndNT2 - cmp #$23 - bne ClearInputLineModifyAddr - lda (addrtmp + 1) - cmp #$C0 - bcc ClearInputLineStart -ClearInputLineModifyAddr: - lda (addrtmp + 1) - sec - sbc #$C0 - sta (addrtmp + 1) - lda addrtmp - adc #$04 - sta addrtmp - jmp ClearInputLineStart -ClearInputLineCheckEndNT2: - cmp #$2B - bcc ClearInputLineStart - bne ClearInputLineModifyAddrNT2 - lda (addrtmp + 1) - cmp #$C0 - bcc ClearInputLineStart -ClearInputLineModifyAddrNT2: - lda (addrtmp + 1) - sec - sbc #$C0 - sta (addrtmp + 1) - lda addrtmp - sbc #$0B - sta addrtmp -ClearInputLineStart: - lda #$00 - sta (drawbuffer), y - iny - lda addrtmp - sta (drawbuffer), y - iny - lda (addrtmp + 1) - sta (drawbuffer), y - iny - ldx #28 - lda #$79 + + lda #$00 + sta (drawbuffer), y + iny + lda addrtmp + sta (drawbuffer), y + iny + lda (addrtmp + 1) + sta (drawbuffer), y + iny + ldx #28 + lda #$79 ClearInputLineLoop: sta (drawbuffer), y iny @@ -869,70 +939,40 @@ ClearLineBackground: and #%11100000 clc adc #$2A - sta (addrtmp + 1) + sta (nametableaddrtmp + 1) lda textaddr adc #$00 + sta nametableaddrtmp + + jsr UpdateNametable + + lda (nametableaddrtmp + 1) + sta (addrtmp + 1) + lda nametableaddrtmp sta addrtmp -ClearLineBackgroundCheckNT0: - cmp #$23 - bcc ClearLineBackgroundStart - cmp #$25 - bcs ClearLineBackgroundCheckNT2 - cmp #$23 - bne ClearLineBackgroundModifyAddr - lda (addrtmp + 1) - cmp #$C0 - bcc ClearLineBackgroundStart -ClearLineBackgroundModifyAddr: - lda (addrtmp + 1) - sec - sbc #$C0 - sta (addrtmp + 1) - lda addrtmp - adc #$04 - sta addrtmp - jmp ClearLineBackgroundStart -ClearLineBackgroundCheckNT2: - cmp #$2B - bcc ClearLineBackgroundStart - bne ClearLineBackgroundModifyAddrNT2 - lda (addrtmp + 1) - cmp #$C0 - bcc ClearLineBackgroundStart -ClearLineBackgroundModifyAddrNT2: - lda (addrtmp + 1) - sec - sbc #$C0 - sta (addrtmp + 1) - lda addrtmp - sbc #$0B - sta addrtmp -ClearLineBackgroundStart: - ldy drawbufferoffset - lda #$00 - sta (drawbuffer), y - iny - lda addrtmp - sta (drawbuffer), y - iny - lda (addrtmp + 1) - sta (drawbuffer), y - iny - ldx #20 - lda #$79 - nop - nop + + ldy drawbufferoffset + lda #$00 + sta (drawbuffer), y + iny + lda addrtmp + sta (drawbuffer), y + iny + lda (addrtmp + 1) + sta (drawbuffer), y + iny + ldx #20 + lda #$79 ClearLineBackgroundLoop: sta (drawbuffer), y iny dex bne ClearLineBackgroundLoop - sty drawbufferoffset + sty drawbufferoffset ClearLinesBackgroundDone: rts DrawLineBackground: - jsr ClearLineBackground lda textrow cmp #21 bcc DrawLineBackgroundDone @@ -940,57 +980,28 @@ DrawLineBackground: and #%11100000 clc adc #$4A - sta (addrtmp + 1) + sta (nametableaddrtmp + 1) lda textaddr adc #$00 + sta nametableaddrtmp + jsr UpdateNametable + lda (nametableaddrtmp + 1) + sta (addrtmp + 1) + lda nametableaddrtmp sta addrtmp -DrawLineBackgroundCheckNT0: - cmp #$23 - bcc DrawLineBackgroundStart - cmp #$25 - bcs DrawLineBackgroundCheckNT2 - cmp #$23 - bne DrawLineBackgroundModifyAddr - lda (addrtmp + 1) - cmp #$C0 - bcc DrawLineBackgroundStart -DrawLineBackgroundModifyAddr: - lda (addrtmp + 1) - sec - sbc #$C0 - sta (addrtmp + 1) - lda addrtmp - adc #$04 - sta addrtmp - jmp DrawLineBackgroundStart -DrawLineBackgroundCheckNT2: - cmp #$2B - bcc DrawLineBackgroundStart - bne DrawLineBackgroundModifyAddrNT2 - lda (addrtmp + 1) - cmp #$C0 - bcc DrawLineBackgroundStart -DrawLineBackgroundModifyAddrNT2: - lda (addrtmp + 1) - sec - sbc #$C0 - sta (addrtmp + 1) - lda addrtmp - sbc #$0B - sta addrtmp -DrawLineBackgroundStart: - ldy drawbufferoffset - lda #$00 - sta (drawbuffer), y - iny - lda addrtmp - sta (drawbuffer), y - iny - lda (addrtmp + 1) - sta (drawbuffer), y - iny - ldx #20 - lda #$0D + + ldy drawbufferoffset + lda #$00 + sta (drawbuffer), y + iny + lda addrtmp + sta (drawbuffer), y + iny + lda (addrtmp + 1) + sta (drawbuffer), y + iny + ldx #20 + lda #$0D DrawLineBackgroundLoop: sta (drawbuffer), y iny @@ -1003,6 +1014,7 @@ DrawLineBackgroundDone: DrawInputText: ldy drawbufferoffset lda #$00 + sta deleteoffset sta (drawbuffer), y iny lda textaddr @@ -1045,48 +1057,36 @@ DrawInputTextNewLine: inc textrow lda textrow cmp #22 - bne DrawInputTextNewLineNotScrollNT0 + bne DrawInputTextNewLineNotScroll + inc deleteoffset dec textrow lda yscroll clc adc #$08 sta yscroll cmp #240 - bne DrawInputTextNewLineNotScrollNT0 + bne DrawInputTextNewLineNotScroll lda #$00 sta yscroll lda nametable eor #$02 sta nametable sta PPU_CTRL -DrawInputTextNewLineNotScrollNT0: - lda textaddr - cmp #$23 - bne DrawInputTextNewLineNotScrollNT1 - lda (textaddr + 1) - cmp #$C2 - bne DrawInputTextNewLineDone - lda #$28 - sta textaddr - lda #$02 - sta (textaddr + 1) - jmp DrawInputTextNewLineDone -DrawInputTextNewLineNotScrollNT1: +DrawInputTextNewLineNotScroll: lda textaddr - cmp #$2B - bne DrawInputTextNewLineDone - lda (textaddr + 1) - cmp #$C2 - bne DrawInputTextNewLineDone - lda #$20 - sta textaddr - lda #$02 - sta (textaddr + 1) -DrawInputTextNewLineDone: + sta nametableaddrtmp + lda (textaddr + 1) + sta (nametableaddrtmp + 1) + jsr UpdateNametable + lda nametableaddrtmp + sta textaddr + lda (nametableaddrtmp + 1) + sta (textaddr + 1) + lda characters, x cmp #10 bne DrawInputTextNotNewLineCharacter - ldx #24 + ldx #24 jmp DrawInputTextEnd DrawInputTextNotNewLineCharacter: ldy drawbufferoffset