From 32d619c9e79f9e6ab665cf80e3cfb53cb74896c5 Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Wed, 26 Jan 2022 06:41:34 -0500 Subject: [PATCH 1/4] BSOD --- LTTP_RND_GeneralBugfixes.asm | 5 + bsodencode.txt | 71 +++++ bsodfont.1bpp | Bin 0 -> 360 bytes bsodhex.2bpp | Bin 0 -> 4096 bytes failure.asm | 601 +++++++++++++++++++++++++++++++++++ hooks.asm | 22 ++ zsnes.asm | 3 +- 7 files changed, 700 insertions(+), 2 deletions(-) create mode 100644 bsodencode.txt create mode 100644 bsodfont.1bpp create mode 100644 bsodhex.2bpp create mode 100644 failure.asm diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 20030f6..1945dbd 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -183,6 +183,11 @@ org $A1A000 ; static mapping area. Referenced by front end. Do not move. incsrc invertedstatic.asm warnpc $A1A100 +org $A1B000 +incsrc failure.asm +warnpc $A1FF00 + + org $A1FF00 ; static mapping area incsrc init.asm diff --git a/bsodencode.txt b/bsodencode.txt new file mode 100644 index 0000000..81e1890 --- /dev/null +++ b/bsodencode.txt @@ -0,0 +1,71 @@ + =00 +A=01 +a=01 +B=02 +b=02 +C=03 +c=03 +D=04 +d=04 +E=05 +e=05 +F=06 +f=06 +G=07 +g=07 +H=08 +h=08 +I=09 +i=09 +J=0A +j=0A +K=0B +k=0B +L=0C +l=0C +M=0D +m=0D +N=0E +n=0E +O=0F +o=0F +P=10 +p=10 +Q=11 +q=11 +R=12 +r=12 +S=13 +s=13 +T=14 +t=14 +U=15 +u=15 +V=16 +v=16 +W=17 +w=17 +X=18 +x=18 +Y=19 +y=19 +Z=1A +z=1A +0=1B +1=1C +2=1D +3=1E +4=1F +5=20 +6=21 +7=22 +8=23 +9=24 +.=25 +#=26 +?=27 +-=28 +/=29 +,=2A +'=2B +;=2C \ No newline at end of file diff --git a/bsodfont.1bpp b/bsodfont.1bpp new file mode 100644 index 0000000000000000000000000000000000000000..d4d63ab135f1e3945a843cb48521aa6b8993ea12 GIT binary patch literal 360 zcmYLEp%KF{4Ezx?f$WAnS6e%`n3HqNr<@XXPdUe)6j@>%w3CmNralt0!F{>- q?3ard8MB`v4dKt1->gLcgz(-@9$;O8$8)M4ci7?|fr!5xSN;Wee0lEx literal 0 HcmV?d00001 diff --git a/bsodhex.2bpp b/bsodhex.2bpp new file mode 100644 index 0000000000000000000000000000000000000000..fabf08e20960d27ac7392f6090f457f961a83c3b GIT binary patch literal 4096 zcmY*c3u+=k5bd*s5JCtZLPSE4IYbCyS%QZMVF@AR5F(3+cnFaoGRz@FBm|i=?ECag z^>#BRZ(h~ws;-`LOev*NTIM+dB3`ArW+gmHGt7Bfq`)iPn}{FEdyP9o;R==|KNjX1 z)~~YOyvNJ5mWK5m&tF(s-lqr6@P|4Qq7J;yWd^^IxqljGS# zpL$-O`gfYAo_9Xx9S<$6ANX7L+jN6@pWbsk+jN^Qk?(7^uhRwQD7_W<7SX-r^*8db zfSrGnuAvb8mvHDeS?@Kk*T8?E^&Ow%8Tb0e725EfDsWuLzs27R;enp_;ID*3e~|UK0~`bRuTfi`0uIM>>h+CV@HgUbVZV~S z*Qfp>eIvfBo?jNc;~{VTz}K=r;$-cm?s^>4$A9%d<0O{#Cob!Ikbl&_#YrpqlQ5&V zew+2W`nT{e>+g7?{>D-NGwjRyQ-6o-y84rMKCZvxA>Sz9z^?zJ?4v(FDt~?hRI-0o zywU%OYt?Wf{z3lH|EJ2A-x=ngghPLt^}7B)g@25@MQhrXW_ zf5Xs$C!786KI=Ok_J7B3>~9F#pJC7bcb|Fcv;W;C=TH8o;2jTn#~--MpHB<->qvQg zu5hvbt?(I@JOC{U%zLxk{}1r|!4pg?juw_Be-aM;HtVs+*nSBg@?P&KJ=Xs$-k9}w z|3BkDUi{>s{x_~g?*HU|3f}RMw|?Mn`Hy7#8++#G)9*iz=tGV82_l)LN9=LnReHcF zsKxvJXA128Uty(^9}9o`T=!c-a4F@Aav_NWT!D`~RfR z$GqbqZ~ef2{;kg)o9F#-|DPi&4(ETw8iCpWXNZEs`Ln7sVe1F){6pXQ`-IWK`IEQ4 z<2m*E#y%mmXMXJe{N!-{JOO`&oqzC-hrIOzFJ!-k(jM0`*MAG$ts{tnlo|Nigt zG4FWDTR*Vt&;IK9C_VQ7SIwy~`~3^>TMGQ4d(Yz8|KHOm?mP&yzm`1v|A%a>&;C!n zS3FZ3?EjzQt?zjLz{dKK1_J8Y{r@rS?&pRLUj)xZ35By8^++WXa#@+9qM%cAv z{|mfAb-Mbn{ye)pB^=z}l4pHZvavqv&)-vJ{aM|z{!5(YPT%qUUw`Y>T95jke*S$n zsAt~s{9pf-JY4@H_H(cOKT6NAL1kb7vad?eB^Ka$iKr~{??ED?H~ES=XkpOL*M!T>3QdGKJvAG;J5S-k5pj} literal 0 HcmV?d00001 diff --git a/failure.asm b/failure.asm new file mode 100644 index 0000000..8ee53ee --- /dev/null +++ b/failure.asm @@ -0,0 +1,601 @@ +pushtable + +table "bsodencode.txt" + +; Uncomment this to force a crash to test message +;pushpc +; org $8132 : db 0 +;pullpc + +;=================================================================================================== + +DontUseZSNES: + SEP #$35 ; sets carry and I flag too + LDA.b #$00 + STA.l $4200 ; disable NMI and IRQ + STA.l $420C ; disable HDMA + + ROR ; A = 0x80 from carry + STA.l $2100 + STA.l $2115 + + ; Empty VRAM + SEP #$20 + + LDA.b #AllZeros>>16 : STA.l $4304 + + REP #$20 + + LDA.w #AllZeros + STA.l $4302 + + LDA.w #$1809 + STA.l $4300 + + LDA.w #$0000 + STA.l $4305 + + LDA.w #$0001 + STA.l $420B + + JSR ConfigurePPUForFailureReport + JSR ConfigureBSODVWF + + STZ.b VWFR + LDA.w #ZSNESMessage_line1 : JSR DrawVWFLine + LDA.w #ZSNESMessage_line2 : JSR DrawVWFLine + LDA.w #ZSNESMessage_line3 : JSR DrawVWFLine + LDA.w #ZSNESMessage_line4 : JSR DrawVWFLine + LDA.w #ZSNESMessage_line5 : JSR DrawVWFLine + LDA.w #ZSNESMessage_line6 : JSR DrawVWFLine + LDA.w #ZSNESMessage_line7 : JSR DrawVWFLine + + LDA.w #$0F0F + STA.w $2100 + +-- BRA -- + +ZSNESMessage: +.line1 + db "It has been detected that you are attempting to play", $FF + +.line2 + db "this ROM on a low-quality emulator.", $FF + +.line3 + db "The randomizer is designed to work on real hardware,", $FF + +.line4 + db "which this application cannot emulate properly;", $FF + +.line5 + db "As such, this ROM file refuses to boot.", $FF + +.line6 + db "Please upgrade to a more accurate emulator such as", $FF + +.line7 + db "SNES9X or BSNES/higan.", $FF + +;=================================================================================================== + +AllZeros: + db $00 + +UselessStackTooFar: + dw $137 + +Crashed: +;=================================================================================================== +;=================================================================================================== +;=================================================================================================== +; !!!DO NOT TRY TO OPTIMIZE THIS CODE!!! +; IT IS INTENTIONALLY AVOIDING CHANGING CERTAIN REGISTERS, ESPECIALLY THE STACK. +;=================================================================================================== +;=================================================================================================== +;=================================================================================================== + SEP #$35 ; sets carry and I flag too + LDA.b #$00 + STA.l $4200 ; disable NMI and IRQ + STA.l $420C ; disable HDMA + + ROR ; A = 0x80 from carry + STA.l $2100 + STA.l $2115 + + ; Empty VRAM + SEP #$20 + + LDA.b #AllZeros>>16 : STA.l $4304 + + REP #$20 + + LDA.w #AllZeros + STA.l $4302 + + LDA.w #$1809 + STA.l $4300 + + LDA.w #$0000 + STA.l $4305 + + LDA.w #$0001 + STA.l $420B + +;=================================================================================================== + + ; Create report + REP #$30 + + LDA.w #$2100 + TCD + +;--------------------------------------------------------------------------------------------------- + + ; Report status + + ; stack pointer + LDA.w #$0438>>1 + STA.b $2116 + + TSC + XBA + AND.w #$00FF + ORA.w #$0100 + STA.b $2118 + + TSC + AND.w #$00FF + ORA.w #$0100 + STA.l $2118 + + ; game module + LDA.w #$0478>>1 + STA.b $2116 + + LDA.l $10 + AND.w #$00FF + ORA.w #$0100 + STA.b $2118 + + LDA.l $11 + AND.w #$00FF + ORA.w #$0100 + STA.b $2118 + +;--------------------------------------------------------------------------------------------------- + + ; Report stack + TSC + INC + STA.l $7F0100 + + ; For now, we can report as much of the stack as possible + ; If desired later on, uncomment the code below to keep the stack limited to + ; where it was last doing stuff + LDA.l UselessStackTooFar ; also comment out this line when doing the above + +; TSC +; +; ; keep stack in a useful range +; CMP.w #$01FF ; this means we pulled too much and the stack is useless +; BCC .stack_fine +; +; JMP .skip_stack +; +;.stack_fine +; CMP.l UselessStackTooFar +; BCS .stack_adjusted +; +; ; this means we went too far in, and the stack contains little useful info +; LDA.l UselessStackTooFar +; +;.stack_adjusted + STA.l $7F0000 + + LDX.w #$01FF + + LDA.w #$0404>>1 + +.next_row + STA.l $7F0002 + STA.l $7F0004 + + LDY.w #20 + +.next_char + STA.b $2116 + + TXA + CMP.l $7F0100 + + LDA.l $000000,X + AND.w #$00FF + ORA.w #$0500 + BCS ++ + + AND.w #$01FF + +++ STA.b $2118 + + DEX + TXA + CMP.l $7F0000 + BEQ .skip_stack + + DEY + BEQ .done_row + + LDA.l $7F0002 + INC + STA.l $7F0002 + + BRA .next_char + +.done_row + CLC + LDA.l $7F0004 + ADC.w #32 + BRA .next_row + +;=================================================================================================== +;=================================================================================================== +;=================================================================================================== + ; once the stack is reported, we can start doing stuff that mucks with it +.skip_stack + REP #$30 + SEP #$10 + + LDA.w #$0000 + TCD + TSC + + STA.b $80 ; remember stack for later messages + + JSR ConfigurePPUForFailureReport + JSR ConfigureBSODVWF + JSR LoadBSODFont + + STZ.b VWFR + LDA.w #BSODMessage_line1 : JSR DrawVWFLine + LDA.w #BSODMessage_line2 : JSR DrawVWFLine + LDA.w #BSODMessage_line3 : JSR DrawVWFLine + LDA.w #BSODMessage_line4 : JSR DrawVWFLine + LDA.w #BSODMessage_line5 : JSR DrawVWFLine + LDA.w #BSODMessage_line6 : JSR DrawVWFLine + LDA.w #BSODMessage_line7 : JSR DrawVWFLine + + + LDA.w #$0F0F + STA.w $2100 + +-- BRA -- +; LDA.w #$0000 +; TCD +; +; TSC + + +BSODMessage: +.line1 + db "A fatal error has occurred and resulted in an", $FF + +.line2 + db "unrecoverable crash. ?", $FF + +.line3 + db "If you believe this is the result of a bug caused by", $FF + +.line4 + db "the randomizer itself, please screenshot this message", $FF + +.line5 + db "and share it in the #bug-reports channel of the official", $FF + +.line6 + db "ALTTPR discord, along with a detailed description of", $FF + +.line7 + db "what you were doing, including video if available.", $FF + +;=================================================================================================== + +DrawVWFLine: + STA.b $06 + +.next + LDA.b ($06) + AND.w #$00FF + CMP.w #$00FF + BEQ .done_row + + JSR DrawFailureVWFChar + + INC.b $06 + BRA .next + +.done_row + LDA.b VWFR + ASL + TAX + LDA.w .row_offset,X + STA.w $2116 + + INC.b VWFR + + LDA.w #$1800 + STA.w $4300 + + LDA.w #20*16 + STA.w $4305 + + LDA.w #$1000 + STA.w $4302 + + SEP #$20 + + STZ.w $2115 + STZ.w $4304 + + LDA.b #$01 + STA.w $420B + + LDA.b #$80 + STA.w $2115 + + REP #$20 + + JMP ResetVFW + +.row_offset + dw $10F8 + dw $11E8 + dw $12D8 + dw $13C8 + dw $14B8 + dw $15A8 + dw $1698 + dw $1788 + + + +;=================================================================================================== + +VWFL = $40 +VWFX = $44 +VWFS = $46 +VWFP = $48 +VWFR = $4A + +;=================================================================================================== + +DrawFailureVWFChar: + REP #$30 + PHY + PHX + + AND.w #$00FF + STA.b VWFL + + TAX + + ASL + ASL + ASL + ADC.w #BSODFontGFX + STA.b $08 + + LDA.b VWFP + AND.w #$FFF8 + STA.w VWFX + + LDA.b VWFP + AND.w #$0007 + STA.w VWFS + + SEC + LDA.w BSODCharWidths,X + AND.w #$00FF + ADC.b VWFP + STA.b VWFP + + LDY.w #$0000 + +.next_row + LDA.b ($08),Y + AND.w #$00FF + XBA + LDX.w VWFS + BEQ ++ + +-- LSR + DEX + BNE -- + +++ LDX.w VWFX + SEP #$20 + ORA.w $1008,X + STA.w $1008,X + + XBA + ORA.w $1000,X + STA.w $1000,X + + REP #$20 + INX + STX.w VWFX + + INY + CPY.w #$0008 + BCC .next_row + + REP #$30 + PLX + PLY + + RTS + +;=================================================================================================== + +LoadBSODFont: + REP #$20 + + LDA.w #BSODHex + STA.w $4302 + + LDA.w #$1801 + STA.w $4300 + + LDA.w #$1000 + STA.w $4305 + + LDA.w #$1800 + STA.w $2116 + + SEP #$20 + LDA.b #BSODHex>>16 + STA.w $4304 + + LDA.b #$01 + STA.w $420B + + REP #$30 + + RTS + +;=================================================================================================== + +ConfigureBSODVWF: + REP #$30 + + LDA.w #$2100 + TCD + + SEP #$20 + STZ.b $2121 + + STZ.b $2122 + STZ.b $2122 + + LDA.b #$FF + STA.b $2122 + LDA.b #$7F + STA.b $2122 + + STZ.b $2122 + STZ.b $2122 + + STZ.b $2122 + STZ.b $2122 + + STZ.b $2122 + STZ.b $2122 + + LDA.b #$11 + STA.b $2122 + LDA.b #$7F + STA.b $2122 + + REP #$20 + + + PEA.w $0001 + + LDA.w #8 + STA.w $28 + + LDA.w #$0042>>1 + BRA .start + +.next_row + PHA + + LDA.w $20 + CLC + LDA.w $20 + ADC.w #32 + +.start + STA.w $20 + STA.b $2116 + + PLA + + LDY.w #30 + +.next_char + STA.b $2118 + INC + DEY + BNE .next_char + + DEC.w $28 + BNE .next_row + + LDA.w #$0000 + TCD + +ResetVFW: + REP #$30 + LDX.w #$0400 + +-- STZ.w $1000,X + DEX + DEX + BPL -- + + STZ.b VWFL + STZ.b VWFX + STZ.b VWFS + STZ.b VWFP + + RTS + +;=================================================================================================== + +ConfigurePPUForFailureReport: + SEP #$30 + + PHK + PLB + + STZ.w $2105 ; BG mode 0 + STZ.w $2106 ; no mosaic + STZ.w $2107 ; BG1 tilemap to $0000 + STZ.w $210D + STZ.w $210D + STZ.w $210E + STZ.w $210E + STZ.w $2123 + STZ.w $2131 + STZ.w $2133 + + + LDA.b #$01 + STA.w $210B + STA.w $212C + STA.w $212D + + RTS + +;=================================================================================================== + +BSODHex: +incbin "bsodhex.2bpp" + +BSODFontGFX: +incbin "bsodfont.1bpp" + +BSODCharWidths: + ; [space] + db 3 + + ; A B C D E F G H I J K L M N O P Q R S T U V W X Y Z + db 4, 4, 4, 4, 3, 3, 4, 3, 1, 4, 3, 3, 5, 4, 4, 4, 5, 4, 4, 3, 4, 5, 5, 3, 5, 3 + + ; 0 1 2 3 4 5 6 7 8 9 . # ? - / , ' + db 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 8, 3, 3, 2, 1 + +;=================================================================================================== + +pulltable diff --git a/hooks.asm b/hooks.asm index f0534dd..2965289 100755 --- a/hooks.asm +++ b/hooks.asm @@ -38,6 +38,28 @@ JML.l CheckZSNES ReturnCheckZSNES: ;-------------------------------------------------------------------------------- +;================================================================================ +; Ok so basically, in rare cases, major glitches may try to read far into the +; A bus until they reach a value of $FFFF +; For maximum security of vanilla behavior, I am reserving this space +; that could otherwise be considered free ROM. +;-------------------------------------------------------------------------------- +org $0089C2 +dw $FFFF, $FFFF, $FFFF, $FFFF +dw $FFFF, $FFFF, $FFFF, $FFFF +dw $FFFF, $FFFF, $FFFF, $FFFF + +;================================================================================ +; BSOD for BRK and COP opcodes +;-------------------------------------------------------------------------------- +org $00FFB7 +SoftwareInterrupt: +JML Crashed + +org $00FFE4 : dw SoftwareInterrupt +org $00FFE6 : dw SoftwareInterrupt +org $00FFF4 : dw SoftwareInterrupt + ;================================================================================ ; Dungeon Entrance Hook (works, but not needed at the moment) ;-------------------------------------------------------------------------------- diff --git a/zsnes.asm b/zsnes.asm index 5c27ec6..734defb 100644 --- a/zsnes.asm +++ b/zsnes.asm @@ -11,6 +11,5 @@ CheckZSNES: LDA #$01FF : TCS ; thing we wrote over - initialize stack JML.l ReturnCheckZSNES .zsnes - -STP ; ! + JML DontUseZSNES ;-------------------------------------------------------------------------------- From a247a0ae01ae02f81f81e9f3366134db21166d24 Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Wed, 26 Jan 2022 08:22:44 -0500 Subject: [PATCH 2/4] tinker tinker --- bsodfont.1bpp | Bin 360 -> 360 bytes failure.asm | 43 +++++++++++++------------------------------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/bsodfont.1bpp b/bsodfont.1bpp index d4d63ab135f1e3945a843cb48521aa6b8993ea12..2c8e2f8fc22e35a393381a327ea6587428950414 100644 GIT binary patch literal 360 zcmX|6u@S>C2xJ70pu%IM;4*1s;0Z0dx;{Anc`Y+h$Vw`s)EcUULqhJJvNd zfqKr*cN{8PBxfuj?ByS$_Xa-ZygJaGYYwn{(YW3T)fshO%mG|qeKiEQdb9?_zlw{l n@}s}*Vcg58i%a>Cl4AD@LA38gw|j~dc{H@uKawE%=cLI$9qMUU literal 360 zcmYLEp%KF{4Ezx?f$WAnS6e%`n3HqNr<@XXPdUe)6j@>%w3CmNralt0!F{>- q?3ard8MB`v4dKt1->gLcgz(-@9$;O8$8)M4ci7?|fr!5xSN;Wee0lEx diff --git a/failure.asm b/failure.asm index 8ee53ee..bf50ee6 100644 --- a/failure.asm +++ b/failure.asm @@ -11,6 +11,7 @@ table "bsodencode.txt" DontUseZSNES: SEP #$35 ; sets carry and I flag too + LDA.b #$00 STA.l $4200 ; disable NMI and IRQ STA.l $420C ; disable HDMA @@ -20,8 +21,6 @@ DontUseZSNES: STA.l $2115 ; Empty VRAM - SEP #$20 - LDA.b #AllZeros>>16 : STA.l $4304 REP #$20 @@ -57,7 +56,7 @@ DontUseZSNES: ZSNESMessage: .line1 - db "It has been detected that you are attempting to play", $FF + db "It has been detected that you are attempting to load", $FF .line2 db "this ROM on a low-quality emulator.", $FF @@ -69,7 +68,7 @@ ZSNESMessage: db "which this application cannot emulate properly;", $FF .line5 - db "As such, this ROM file refuses to boot.", $FF + db "as such, this ROM file refuses to boot.", $FF .line6 db "Please upgrade to a more accurate emulator such as", $FF @@ -95,6 +94,7 @@ Crashed: ;=================================================================================================== ;=================================================================================================== SEP #$35 ; sets carry and I flag too + LDA.b #$00 STA.l $4200 ; disable NMI and IRQ STA.l $420C ; disable HDMA @@ -104,11 +104,9 @@ Crashed: STA.l $2115 ; Empty VRAM - SEP #$20 - LDA.b #AllZeros>>16 : STA.l $4304 - REP #$20 + REP #$38 LDA.w #AllZeros STA.l $4302 @@ -125,8 +123,6 @@ Crashed: ;=================================================================================================== ; Create report - REP #$30 - LDA.w #$2100 TCD @@ -234,6 +230,7 @@ Crashed: .done_row CLC + LDA.l $7F0004 ADC.w #32 BRA .next_row @@ -243,20 +240,18 @@ Crashed: ;=================================================================================================== ; once the stack is reported, we can start doing stuff that mucks with it .skip_stack - REP #$30 - SEP #$10 - LDA.w #$0000 TCD - TSC - STA.b $80 ; remember stack for later messages +; TSC +; STA.b $80 ; remember stack for later messages JSR ConfigurePPUForFailureReport JSR ConfigureBSODVWF JSR LoadBSODFont STZ.b VWFR + LDA.w #BSODMessage_line1 : JSR DrawVWFLine LDA.w #BSODMessage_line2 : JSR DrawVWFLine LDA.w #BSODMessage_line3 : JSR DrawVWFLine @@ -265,7 +260,6 @@ Crashed: LDA.w #BSODMessage_line6 : JSR DrawVWFLine LDA.w #BSODMessage_line7 : JSR DrawVWFLine - LDA.w #$0F0F STA.w $2100 @@ -293,7 +287,7 @@ BSODMessage: db "and share it in the #bug-reports channel of the official", $FF .line6 - db "ALTTPR discord, along with a detailed description of", $FF + db "ALTTPR discord along with a detailed description of", $FF .line7 db "what you were doing, including video if available.", $FF @@ -340,9 +334,6 @@ DrawVWFLine: LDA.b #$01 STA.w $420B - LDA.b #$80 - STA.w $2115 - REP #$20 JMP ResetVFW @@ -370,10 +361,6 @@ VWFR = $4A ;=================================================================================================== DrawFailureVWFChar: - REP #$30 - PHY - PHX - AND.w #$00FF STA.b VWFL @@ -393,6 +380,7 @@ DrawFailureVWFChar: AND.w #$0007 STA.w VWFS + ; carry set on purpose to add letter spacing SEC LDA.w BSODCharWidths,X AND.w #$00FF @@ -429,10 +417,6 @@ DrawFailureVWFChar: CPY.w #$0008 BCC .next_row - REP #$30 - PLX - PLY - RTS ;=================================================================================================== @@ -498,7 +482,6 @@ ConfigureBSODVWF: REP #$20 - PEA.w $0001 LDA.w #8 @@ -537,6 +520,7 @@ ConfigureBSODVWF: ResetVFW: REP #$30 + LDX.w #$0400 -- STZ.w $1000,X @@ -570,7 +554,6 @@ ConfigurePPUForFailureReport: STZ.w $2131 STZ.w $2133 - LDA.b #$01 STA.w $210B STA.w $212C @@ -591,7 +574,7 @@ BSODCharWidths: db 3 ; A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - db 4, 4, 4, 4, 3, 3, 4, 3, 1, 4, 3, 3, 5, 4, 4, 4, 5, 4, 4, 3, 4, 5, 5, 3, 5, 3 + db 4, 4, 3, 4, 3, 3, 4, 3, 1, 4, 3, 3, 5, 4, 4, 4, 5, 4, 4, 3, 4, 5, 5, 3, 3, 3 ; 0 1 2 3 4 5 6 7 8 9 . # ? - / , ' db 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 8, 3, 3, 2, 1 From 8f74ddab05a172cf07eebf54addc074d03ceb90d Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Thu, 27 Jan 2022 01:24:28 -0500 Subject: [PATCH 3/4] fix forgot to account for the stack pointer being screwed up when we start using the stack again might as well add in better VWF control and move hex to BG2 for more space --- failure.asm | 197 ++++++++++++++++++++++++---------------------------- 1 file changed, 89 insertions(+), 108 deletions(-) diff --git a/failure.asm b/failure.asm index bf50ee6..863c557 100644 --- a/failure.asm +++ b/failure.asm @@ -3,9 +3,7 @@ pushtable table "bsodencode.txt" ; Uncomment this to force a crash to test message -;pushpc -; org $8132 : db 0 -;pullpc +;pushpc : org $008132 : db 0 : pullpc ;=================================================================================================== @@ -41,13 +39,8 @@ DontUseZSNES: JSR ConfigureBSODVWF STZ.b VWFR - LDA.w #ZSNESMessage_line1 : JSR DrawVWFLine - LDA.w #ZSNESMessage_line2 : JSR DrawVWFLine - LDA.w #ZSNESMessage_line3 : JSR DrawVWFLine - LDA.w #ZSNESMessage_line4 : JSR DrawVWFLine - LDA.w #ZSNESMessage_line5 : JSR DrawVWFLine - LDA.w #ZSNESMessage_line6 : JSR DrawVWFLine - LDA.w #ZSNESMessage_line7 : JSR DrawVWFLine + LDA.w #ZSNESMessage + JSR DrawVWFMessage LDA.w #$0F0F STA.w $2100 @@ -55,26 +48,14 @@ DontUseZSNES: -- BRA -- ZSNESMessage: -.line1 - db "It has been detected that you are attempting to load", $FF - -.line2 - db "this ROM on a low-quality emulator.", $FF - -.line3 - db "The randomizer is designed to work on real hardware,", $FF - -.line4 - db "which this application cannot emulate properly;", $FF - -.line5 - db "as such, this ROM file refuses to boot.", $FF - -.line6 - db "Please upgrade to a more accurate emulator such as", $FF - -.line7 - db "SNES9X or BSNES/higan.", $FF + db "It has been detected that you are attempting to load", $80 + db "this ROM on a low-quality emulator.", $80 + db "The randomizer is designed to work on real hardware,", $80 + db "which this application cannot emulate properly;", $80 + db "as such, this ROM file refuses to boot.", $80 + db "Please upgrade to a more accurate emulator such as", $80 + db "SNES9X or BSNES/higan.", $80 + db $FF ;=================================================================================================== @@ -131,7 +112,7 @@ Crashed: ; Report status ; stack pointer - LDA.w #$0438>>1 + LDA.w #$0C38>>1 STA.b $2116 TSC @@ -146,7 +127,7 @@ Crashed: STA.l $2118 ; game module - LDA.w #$0478>>1 + LDA.w #$0C78>>1 STA.b $2116 LDA.l $10 @@ -166,11 +147,11 @@ Crashed: INC STA.l $7F0100 + LDA.l UselessStackTooFar + ; For now, we can report as much of the stack as possible ; If desired later on, uncomment the code below to keep the stack limited to ; where it was last doing stuff - LDA.l UselessStackTooFar ; also comment out this line when doing the above - ; TSC ; ; ; keep stack in a useful range @@ -191,28 +172,29 @@ Crashed: LDX.w #$01FF - LDA.w #$0404>>1 + LDA.w #$0C04>>1 .next_row - STA.l $7F0002 STA.l $7F0004 + STA.b $2116 LDY.w #20 -.next_char - STA.b $2116 - TXA + +.next_char + ; set carry to see if we should color this value as being in the stack CMP.l $7F0100 LDA.l $000000,X AND.w #$00FF ORA.w #$0500 - BCS ++ + BCS .in_stack AND.w #$01FF -++ STA.b $2118 +.in_stack + STA.b $2118 DEX TXA @@ -220,13 +202,7 @@ Crashed: BEQ .skip_stack DEY - BEQ .done_row - - LDA.l $7F0002 - INC - STA.l $7F0002 - - BRA .next_char + BNE .next_char .done_row CLC @@ -246,24 +222,23 @@ Crashed: ; TSC ; STA.b $80 ; remember stack for later messages + LDA.w #$01FF + TCS + JSR ConfigurePPUForFailureReport JSR ConfigureBSODVWF - JSR LoadBSODFont + JSR LoadBSODHexFont STZ.b VWFR - LDA.w #BSODMessage_line1 : JSR DrawVWFLine - LDA.w #BSODMessage_line2 : JSR DrawVWFLine - LDA.w #BSODMessage_line3 : JSR DrawVWFLine - LDA.w #BSODMessage_line4 : JSR DrawVWFLine - LDA.w #BSODMessage_line5 : JSR DrawVWFLine - LDA.w #BSODMessage_line6 : JSR DrawVWFLine - LDA.w #BSODMessage_line7 : JSR DrawVWFLine + LDA.w #BSODMessage + JSR DrawVWFMessage LDA.w #$0F0F STA.w $2100 -- BRA -- + ; LDA.w #$0000 ; TCD ; @@ -271,43 +246,39 @@ Crashed: BSODMessage: -.line1 - db "A fatal error has occurred and resulted in an", $FF - -.line2 - db "unrecoverable crash. ?", $FF - -.line3 - db "If you believe this is the result of a bug caused by", $FF - -.line4 - db "the randomizer itself, please screenshot this message", $FF - -.line5 - db "and share it in the #bug-reports channel of the official", $FF - -.line6 - db "ALTTPR discord along with a detailed description of", $FF - -.line7 - db "what you were doing, including video if available.", $FF + db "A fatal error has occurred and resulted in an", $80 + db "unrecoverable crash. ?", $80 + db "If you believe this was the result of a bug caused by", $80 + db "the randomizer itself, please screenshot this message", $80 + db "and share it in the #bug-reports channel of the official", $80 + db "ALTTPR discord along with a detailed description of", $80 + db "what you were doing, including video if available.", $80 + db "Please also make a savestate now and include that in", $80 + db "your report.", $80 + db $FF ;=================================================================================================== -DrawVWFLine: +DrawVWFMessage: STA.b $06 .next LDA.b ($06) + INC.b $06 AND.w #$00FF - CMP.w #$00FF + CMP.w #$0080 BEQ .done_row + CMP.w #$00FF + BEQ .done_message + JSR DrawFailureVWFChar - INC.b $06 BRA .next +.done_message + RTS + .done_row LDA.b VWFR ASL @@ -336,7 +307,10 @@ DrawVWFLine: REP #$20 - JMP ResetVFW + JSR ResetVFW + + BRA .next + .row_offset dw $10F8 @@ -347,6 +321,9 @@ DrawVWFLine: dw $15A8 dw $1698 dw $1788 + dw $1878 + dw $1968 + dw $1A58 @@ -421,7 +398,7 @@ DrawFailureVWFChar: ;=================================================================================================== -LoadBSODFont: +LoadBSODHexFont: REP #$20 LDA.w #BSODHex @@ -433,7 +410,7 @@ LoadBSODFont: LDA.w #$1000 STA.w $4305 - LDA.w #$1800 + LDA.w #$2800 STA.w $2116 SEP #$20 @@ -455,36 +432,32 @@ ConfigureBSODVWF: LDA.w #$2100 TCD - SEP #$20 + SEP #$30 + + LDX.b #$FF + LDY.b #$7F + STZ.b $2121 + STZ.b $2122 : STZ.b $2122 - STZ.b $2122 - STZ.b $2122 + STX.b $2122 : STY.b $2122 - LDA.b #$FF - STA.b $2122 - LDA.b #$7F - STA.b $2122 + LDA.b #$05 + STA.b $2121 - STZ.b $2122 - STZ.b $2122 + LDA.b #$11 : STA.b $2122 : STY.b $2122 - STZ.b $2122 - STZ.b $2122 + LDA.b #$21 : STA.b $2121 + STX.b $2122 : STY.b $2122 - STZ.b $2122 - STZ.b $2122 + LDA.b #$25 : STA.b $2121 + LDA.b #$11 : STA.b $2122 : STY.b $2122 - LDA.b #$11 - STA.b $2122 - LDA.b #$7F - STA.b $2122 - - REP #$20 + REP #$30 PEA.w $0001 - LDA.w #8 + LDA.w #15 STA.w $28 LDA.w #$0042>>1 @@ -546,18 +519,26 @@ ConfigurePPUForFailureReport: STZ.w $2105 ; BG mode 0 STZ.w $2106 ; no mosaic STZ.w $2107 ; BG1 tilemap to $0000 - STZ.w $210D - STZ.w $210D - STZ.w $210E - STZ.w $210E + STZ.w $212D + + STZ.w $210D : STZ.w $210D + STZ.w $210E : STZ.w $210E + STZ.w $210F : STZ.w $210F + STZ.w $2110 : STZ.w $2110 + + STZ.w $2123 STZ.w $2131 STZ.w $2133 - LDA.b #$01 + LDA.b #$04 + STA.w $2108 ; BG1 tilemap to $0800 + + LDA.b #$21 STA.w $210B + + LDA.b #$03 STA.w $212C - STA.w $212D RTS From 638967ee9c17bc71a9e921c3929ab5257cb1db6f Mon Sep 17 00:00:00 2001 From: Kara Alexandra Date: Sat, 2 Apr 2022 10:07:03 -0700 Subject: [PATCH 4/4] unscramble lowercase letters for new font --- LTTP_RND_GeneralBugfixes.asm | 5 +++++ text_unscramble1.bin | Bin 0 -> 320 bytes text_unscramble2.bin | Bin 0 -> 2048 bytes 3 files changed, 5 insertions(+) create mode 100644 text_unscramble1.bin create mode 100644 text_unscramble2.bin diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 2e5ae7d..4fb84b7 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -290,6 +290,11 @@ if !FEATURE_NEW_TEXT incbin newfont.bin NewFontInverted: incbin newfont_inverted.bin + + org $0CD7DF + incbin text_unscramble1.bin + org $0CE4D5 + incbin text_unscramble2.bin endif org $328000 diff --git a/text_unscramble1.bin b/text_unscramble1.bin new file mode 100644 index 0000000000000000000000000000000000000000..532ec83bd5749de6ee7b33dc6b63dc20968be605 GIT binary patch literal 320 zcmXwuMOT#p00jv_x{>bgZt0Ldbfa`5Al;ydba(DS8tG>BWFEhX#pAo1IWt#ET1NH* zxO;edd6SZwmYxCS6_xeh+1dTO2MUTx$|~UF>*pUpPHtX)0W`F>wfC}raCih7np)aA z5E%41IE13&lF~Bh>;FCchvSpef1qz*Xk-kbVc`*xR8`m1*1_b|^vo=0=NFe?ZeeL< z4N=iCUt(!&`qA71bMp&}OI%&w+=9J>qmwhl5ucDqM`u@e53Fx&Zf$dS|L_QM@*h>z zc;CR_&tF5Zyt2v~PtT%PP}lvWXCnNWWRWe1gr;UTws!FUMJ$Gq(XsIf;g=*ASGS~O NAr*f8hDZ8;2@5O`VCm%?U|D+aaDad@Rv^J%fCTQn*}L=(p+k&?fHD+YKpA7~ zy?4|Yd+!}J#@?|3D(e5t+&kHoMzk0jqY0WKOp5L!jairto12(7D<@A( zds+u{L?ck562@y0$0N37v_HDCdHgYI~fx(36l|~Jm{O5TX1pk`5Wf9%FPpV4((h_#WYMu zn2Mn9V(!LO!RLd_L(28UL}?As5ZP#kqeV1-8`>=s(}wM~Xa|kXI9gh89oKG^#GA9- z13l3T1C(1M@h-Fx7>QBHQSM%eT(8`H61iWwbrK)Qw}WszPQZ!E%aZtb+60`5vv9WZ zk`m9S6<`W3!B*wvNxYC&gc-ORdz5=vqK){?V%pOZZBOfmB;Lcn|yV32dfvH4W2Is8b0sxA1Z+ZVNW-)@$@H@fE(tkFY7=Y6@n; z(WzW9kMQy+9t$??)~ED8@Fx!7Fl>srnt?@FtW%Ddr+BHs)4_(_`icHCqHHxlL)f@X z55-97RH>LZ*?J3aBh0__|Imi5wrB^NCCsH*hUGd{Ddt7CUc$==lg(>0G)Gq?VB<5> zn1$IoRW0U2u0F!Y8P}TE&gg={7y_FW%o41`DxIno^Ep>__#)%F8?Q-pM-TMGCd|QH z%)@-`N5uTf)o=Jc<9aBs!!R5pFcS89HP&D))@eT><~y#w#}66T{dnz<0T_ruu-6N) z5F1gd{ai7BarHO;$+#ZN>p0|KJSM(R-s$@LgYRZ~4E? z&oY!_tM*I9w4}8{YlIm^9}N?HHzv5=!RMW*z#i>aO6-Q4e1Y3^vPkI#*&(1fMFjf8fa9_Wv