Commit: 52b24e8e6d02b877837bf1a1e5ea31f3beee6a88 Author: Vi Grey Date: 2020-08-24 06:35 UTC Summary: Initial Commit Makefile | 32 +++++ README.md | 82 +++++++++++ bin/airgap2020-nes-v1_0_0.nes | Bin 0 -> 393232 bytes src/airgap2020-nes.asm | 121 ++++++++++++++++ src/chat.asm | 152 ++++++++++++++++++++ src/controls.asm | 621 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/decompress.asm | 151 +++++++++++++++++++ src/defs.asm | 51 +++++++ src/draw.asm | 518 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/graphics/ascii.bin | Bin 0 -> 960 bytes src/graphics/bar-top.bin | Bin 0 -> 256 bytes src/graphics/schedule/00.bin | Bin 0 -> 576 bytes src/graphics/schedule/01.bin | Bin 0 -> 576 bytes src/graphics/schedule/02.bin | Bin 0 -> 576 bytes src/graphics/schedule/03.bin | Bin 0 -> 208 bytes src/graphics/schedule/04.bin | Bin 0 -> 576 bytes src/graphics/schedule/05.bin | Bin 0 -> 320 bytes src/graphics/schedule/06.bin | Bin 0 -> 384 bytes src/graphics/schedule/07.bin | Bin 0 -> 384 bytes src/graphics/schedule/08.bin | Bin 0 -> 480 bytes src/graphics/schedule/09.bin | Bin 0 -> 384 bytes src/graphics/schedule/0A.bin | Bin 0 -> 576 bytes src/graphics/schedule/0B.bin | Bin 0 -> 576 bytes src/graphics/schedule/0C.bin | Bin 0 -> 576 bytes src/graphics/schedule/0D.bin | Bin 0 -> 576 bytes src/graphics/schedule/0E.bin | Bin 0 -> 576 bytes src/graphics/schedule/0F.bin | Bin 0 -> 576 bytes src/graphics/schedule/10.bin | Bin 0 -> 576 bytes src/graphics/schedule/11.bin | Bin 0 -> 576 bytes src/graphics/schedule/12.bin | Bin 0 -> 576 bytes src/graphics/schedule/13.bin | Bin 0 -> 576 bytes src/graphics/schedule/14.bin | Bin 0 -> 576 bytes src/graphics/schedule/15.bin | Bin 0 -> 576 bytes src/graphics/title-tileset.chr | Bin 0 -> 8192 bytes src/graphics/twitch-chat-tileset.chr | Bin 0 -> 8192 bytes src/mmc1.asm | 88 ++++++++++++ src/prg.asm | 190 ++++++++++++++++++++++++ src/ram.asm | 73 ++++++++++ src/schedule-text.asm | 604 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/schedule.asm | 159 ++++++++++++++++++++ src/screen.asm | 374 +++++++++++++++++++++++++++++++++++++++++++++++ src/scroll.asm | 47 ++++++ src/title.asm | 205 ++++++++++++++++++++++++++ src/twitchchat/ntsc.txt | Bin 0 -> 119569 bytes src/twitchchat/pal.txt | Bin 0 -> 119535 bytes src/zero.asm | 91 ++++++++++++ 46 files changed, 3559 insertions(+) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..feae015 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +# Copyright (C) 2020, Vi Grey +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +PKG_NAME := airgap2020-nes +CURRENTDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +all: + mkdir -p $(CURRENTDIR)bin; \ + cd $(CURRENTDIR)src; \ + asm $(PKG_NAME).asm ../bin/$(PKG_NAME).nes; \ diff --git a/README.md b/README.md new file mode 100644 index 0000000..3b7b45c --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# **AirGap2020 Commemorative NES ROM** + +------ + +### **IMPORTANT DISCLOSURE!!! READ THIS PLEASE!!!** + +When selecting **TWITCH CHAT** in the NES ROM, you will see the Twitch chat data appear in 1:1 timing with how twitch chat appeared during the conference. **This is the entire Twitch chat log of the event and may contain offensive messages, and offensive usernames.** + +For the sake of archiving the Twitch chat data in its entirety, I will NOT be editing the Twitch chat data. + +Also be aware that messages deleted by moderators in the course of the conference will also appear. + +The Twitch chat data in its entirety can be found in `src/twitchchat/ntsc.txt` and `src/twitchchat/pal.txt`. There is some strange formatting to represent wait time before posting the next message and splits for word/line wrapped text, but the Twitch chat data can be found there. + +There is also no guarantee that all of the Twitch chat data. There is the chance that bot used for logging Twitch chat data may have had networking issues at some point throughout the conference. + +------ + +Commemorative NES ROM for the AirGap2020 conference containing the event schedule and the entire 11 hour Twitch chat log of the event + +_**The AirGap2020 Commemorative NES ROM was created by Vi Grey (https://vigrey.com) and is licensed under the BSD 2-Clause License.**_ + +### Description: + +This is an MMC1 SLROM (256KB PRG, 128KB CHR) commemorative NES ROM for the AirGap2020 digital conference, which occurred on May 2nd, 2020, that contains the event's talk schedule and the entire 11 hours of Twitch Chat data that plays back in 1:1 time (have fun waiting the entire time for the last message to appear...) + +------ + +## **RUNNING THE NES ROM ON AN EMULATOR** + +### Running the NES ROM: +In the main directory of this project, you will find a `bin` directory. Inside of this directory is a file named `airgap2020-nes-v1_0_0.nes`, which can be opened up in an NES emulator. + +------ + +## **BUILDING THE NES ROM FROM THE SOURCE CODE** + +### Build Platforms: +- Linux + +### Build Dependencies: +- **asm6** (You'll probably have to build asm6 from source. Make sure the asm6 binary is named **asm** and that the binary is executable and accessible in your PATH. The source code can be found at http://3dscapture.com/NES/asm6.zip) +- **gmake** (make) + +### Build NES ROM: +From a terminal, go to the the main directory of this project (the directory this README.md file exists in). You can then build the NES ROM with the following command. + +```sh +make +``` + +The resulting NES ROM will be located at `bin/airgap2020-nes.nes` from the main directory. + +------ + +## **LICENSE** +``` +Copyright (C) 2020, Vi Grey +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +``` diff --git a/bin/airgap2020-nes-v1_0_0.nes b/bin/airgap2020-nes-v1_0_0.nes new file mode 100644 index 0000000..3ee705b Binary files /dev/null and b/bin/airgap2020-nes-v1_0_0.nes differ diff --git a/src/airgap2020-nes.asm b/src/airgap2020-nes.asm new file mode 100644 index 0000000..a08ea94 --- /dev/null +++ b/src/airgap2020-nes.asm @@ -0,0 +1,121 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +; Board Type: MMC1 SLROM 256KB PRG ROM 128KB CHR ROM + + .db "NES", $1A + .db $10 + .db $10 + .db %00010000 + .dsb 9, $00 + +.include "ram.asm" +.include "defs.asm" + +.base $8000 + .incbin "twitchchat/ntsc.txt" + .incbin "twitchchat/pal.txt" + +.pad $44000, $FF +.base $C000 + + .include "prg.asm" + .include "chat.asm" + .include "zero.asm" + .include "draw.asm" + .include "title.asm" + .include "schedule.asm" + .include "decompress.asm" + .include "controls.asm" + .include "mmc1.asm" + .include "screen.asm" + .include "scroll.asm" + .include "schedule-text.asm" + + +.pad CALLBACK, #$FF + .dw NMI + .dw RESET + .dw 0 + +.base $0000 + .incbin "graphics/title-tileset.chr" + .incbin "graphics/twitch-chat-tileset.chr" +.pad $4000, $00 + .incbin "graphics/bar-top.bin" +.pad $4200, $00 + .incbin "graphics/ascii.bin" +.pad $4800, $00 + .incbin "graphics/schedule/00.bin" + .incbin "graphics/schedule/01.bin" + .incbin "graphics/schedule/02.bin" +.pad $5000, $00 + .incbin "graphics/bar-top.bin" + .incbin "graphics/ascii.bin" +.pad $5500, $00 + .incbin "graphics/schedule/03.bin" + .incbin "graphics/schedule/04.bin" + .incbin "graphics/schedule/05.bin" + .incbin "graphics/schedule/06.bin" + .incbin "graphics/schedule/07.bin" + .incbin "graphics/schedule/08.bin" + .incbin "graphics/schedule/09.bin" +.pad $6000, $00 + .incbin "graphics/bar-top.bin" +.pad $6200, $00 + .incbin "graphics/ascii.bin" +.pad $6800, $00 + .incbin "graphics/schedule/0A.bin" + .incbin "graphics/schedule/0B.bin" + .incbin "graphics/schedule/0C.bin" +.pad $7000, $00 + .incbin "graphics/bar-top.bin" +.pad $7200, $00 + .incbin "graphics/ascii.bin" +.pad $7800, $00 + .incbin "graphics/schedule/0D.bin" + .incbin "graphics/schedule/0E.bin" + .incbin "graphics/schedule/0F.bin" +.pad $8000, $00 + .incbin "graphics/bar-top.bin" +.pad $8200, $00 + .incbin "graphics/ascii.bin" +.pad $8800, $00 + .incbin "graphics/schedule/10.bin" + .incbin "graphics/schedule/11.bin" + .incbin "graphics/schedule/12.bin" +.pad $9000, $00 + .incbin "graphics/bar-top.bin" +.pad $9200, $00 + .incbin "graphics/ascii.bin" +.pad $9800, $00 + .incbin "graphics/schedule/13.bin" + .incbin "graphics/schedule/14.bin" + .incbin "graphics/schedule/15.bin" +.pad $A000, $00 + .byte $00, $01, $01, $03, $03, $07, $07, $0F + .byte $00, $01, $01, $03, $03, $07, $07, $0F +.pad $20000, $00 diff --git a/src/chat.asm b/src/chat.asm new file mode 100644 index 0000000..18e59f2 --- /dev/null +++ b/src/chat.asm @@ -0,0 +1,152 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +NTSC_START_BANK = $00 +NTSC_START_ADDR_0 = $00 +NTSC_START_ADDR_1 = $80 +PAL_START_ADDR_0 = $11 +PAL_START_ADDR_1 = $93 +PAL_END_ADDR_0 = $00 +PAL_END_ADDR_1 = $A6 + +PAL_START_BANK = $07 +PAL_END_BANK = $1E + +CHAT_END_BANK = $FF + +CHAT_LINE_BEFORE_Y_SCROLL = 28 + + +.enum $0500 + chatByte dsb 1 + chatByteOffset dsb 1 + chatCharactersOffset dsb 1 + chatCharacters dsb 32 +.ende + + +GetChatByte: + ldy #$00 + sty chatByte + jsr ChatLogEnd + lda chatBank + cmp #(CHAT_END_BANK) + beq GetChatByteDone + lda (chatAddr), Y + sta chatByte + cmp #$04 + bcs GetChatByteNotZeroByte + jsr GetZeroCount + rts +GetChatByteNotZeroByte: + jsr IncChatAddr +GetChatByteDone: + rts + + +IncChatAddr: + lda chatAddr + clc + adc #$01 + sta chatAddr + lda (chatAddr + 1) + adc #$00 + sta (chatAddr + 1) + cmp #$C0 + bcc IncChatAddrDone + ; chatAddr is now at least #$C000 + lda #$00 + sta chatAddr + lda #$80 + sta (chatAddr + 1) + inc chatBank + jsr SetMMC1PRGBank +IncChatAddrDone: + rts + + +ChatLogEnd: + lda fps + cmp #60 + bne ChatLogEndNot60FPS + ; FPS is 60 + lda (chatAddr + 1) + cmp #(PAL_START_ADDR_1) + bcc ChatLogEndDone + lda chatAddr + cmp #(PAL_START_ADDR_0) + bcc ChatLogEndDone + lda chatBank + cmp #(PAL_START_BANK) + bcc ChatLogEndDone + lda #(CHAT_END_BANK) + sta chatBank + rts +ChatLogEndNot60FPS: + lda (chatAddr + 1) + cmp #(PAL_END_ADDR_1) + bcc ChatLogEndDone + lda chatAddr + cmp #(PAL_END_ADDR_0) + bcc ChatLogEndDone + lda chatBank + cmp #(PAL_END_BANK) + bcc ChatLogEndDone + lda #(CHAT_END_BANK) + sta chatBank +ChatLogEndDone: + rts + + +HandleChatFrame: + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda ppuAddr + sta (drawBuffer + 1) + iny + lda (ppuAddr + 1) + sta (drawBuffer), Y + iny + sty drawBufferOffset + ldx #$20 +HandleChatFrameLoop: + jsr CheckZeroCount + cmp #$00 + bne HandleChatFrameLoopNotZeroCountZero + jsr GetChatByte + lda chatByte + cmp #$00 + beq HandleChatFrameLoopNotZeroCountZero +HandleChatFrameStarted: + jsr DrawChatByte + jmp HandleChatFrameLoopDone +HandleChatFrameLoopNotZeroCountZero: + jsr DecZeroCount +HandleChatFrameLoopDone: + dex + bne HandleChatFrameLoop + rts diff --git a/src/controls.asm b/src/controls.asm new file mode 100644 index 0000000..92ab097 --- /dev/null +++ b/src/controls.asm @@ -0,0 +1,621 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +CONTROLLER1 = $4016 +CONTROLLER2 = $4017 +CONTROLLER_NONE = 0 +CONTROLLER_STANDARD = 1 +CONTROLLER_SNES_MOUSE = 2 +CONTROLLER_USB_KEYBOARD = 3 + +CONTROLLER_BASIC_KEYBOARD_USED = 1 << 0 +CONTROLLER_FOUR_SCORE_USED = 1 << 1 +CONTROLLER_MOUSE_USED = 1 << 2 +CONTROLLER_MOUSE_READY = 1 << 3 + +FOUR_SCORE_1_SIGNATURE = 1 << 4 +FOUR_SCORE_2_SIGNATURE = 1 << 5 + +CONTROLLER_POLL_LENGTH = 4 + +.enum $0700 + ; Controller Data + ; Controller 1 Data + controller1D0 dsb CONTROLLER_POLL_LENGTH + controller1D1 dsb CONTROLLER_POLL_LENGTH + controller1D2 dsb CONTROLLER_POLL_LENGTH + controller1D3 dsb CONTROLLER_POLL_LENGTH + controller1D4 dsb CONTROLLER_POLL_LENGTH + controller1D0LastFrame dsb CONTROLLER_POLL_LENGTH + controller1D1LastFrame dsb CONTROLLER_POLL_LENGTH + controller1D2LastFrame dsb CONTROLLER_POLL_LENGTH + controller1D3LastFrame dsb CONTROLLER_POLL_LENGTH + controller1D4LastFrame dsb CONTROLLER_POLL_LENGTH + + ; Controller 2 Data + controller2D0 dsb CONTROLLER_POLL_LENGTH + controller2D1 dsb CONTROLLER_POLL_LENGTH + controller2D2 dsb CONTROLLER_POLL_LENGTH + controller2D3 dsb CONTROLLER_POLL_LENGTH + controller2D4 dsb CONTROLLER_POLL_LENGTH + controller2D0LastFrame dsb CONTROLLER_POLL_LENGTH + controller2D1LastFrame dsb CONTROLLER_POLL_LENGTH + controller2D2LastFrame dsb CONTROLLER_POLL_LENGTH + controller2D3LastFrame dsb CONTROLLER_POLL_LENGTH + controller2D4LastFrame dsb CONTROLLER_POLL_LENGTH + + fourScoreDegradeCounter dsb 1 + controller1Type dsb 1 + controller2Type dsb 1 + controller3Type dsb 1 + controller4Type dsb 1 + controllerTmp dsb 1 + controllerMouse dsb 1 + + ; Mouse Data + mouseSensitivity dsb 1 + + ; Keyboard Data + keyboardTmp dsb 1 + basicKeyboard dsb 10 + + keyboardCounter dsb 1 + keyboardASLTmp dsb 1 + keyboardASLCounter dsb 1 + keyboardFlags dsb 1 + + keyboardKeys dsb 4 + keyboardKeysLastFrame dsb 4 + keyboardKeysTmp dsb 4 + keyboardGlyph dsb 1 + keyboardGlyphHeldLastFrame dsb 1 +.ende + + +; controllerGlobalFlags +; 7 bit 0 +; ---- ---- +; || |||| +; || |||+- Famicom BASIC Keyboard Detected Flag +; || ||+-- Four Score Detected Flag +; || |+--- SNES Mouse Detected Flag +; || +---- SNES Mouse Ready Flag +; || +; || +; |+-------- USB Keyboard Detected Flag +; +--------- USB Mouse Detected Flag + + +PollController: + ldx #$00 +PollControllerSetLastFrameLoop: + lda controller1D0, X + sta controller1D0LastFrame, X + lda controller1D1, X + sta controller1D1LastFrame, X + lda controller1D2, X + sta controller1D2LastFrame, X + lda controller1D3, X + sta controller1D3LastFrame, X + lda controller1D4, X + sta controller1D4LastFrame, X + lda controller2D0, X + sta controller2D0LastFrame, X + lda controller2D1, X + sta controller2D1LastFrame, X + lda controller2D2, X + sta controller2D2LastFrame, X + lda controller2D3, X + sta controller2D3LastFrame, X + lda controller2D4, X + sta controller2D4LastFrame, X + lda keyboardKeys, X + sta keyboardKeysLastFrame, X + inx + cpx #CONTROLLER_POLL_LENGTH + bne PollControllerSetLastFrameLoop + lda #$05 + ; Write 5 to $4016 (For Famicom BASIC Keyboard) + sta CONTROLLER1 + + + ; Cycle Mouse Sensitivity Here + ldx #$00 + ldy #$00 +PollControllerLoop: + ; Skip to PollControllerLoopSkipKeyPoll if after first 20 Polls (last is X=2, Y=3) + cpx #$03 + bcs PollControllerLoopSkipKeyboardPoll + ; (X<2 within 20 Polls) + cpx #$02 + bcc PollControllerLoopKeyboardPoll + ; (X=2, Y>=4 is outside 20 Polls) + cpy #$04 + bcs PollControllerLoopSkipKeyboardPoll +PollControllerLoopKeyboardPoll: + tya + and #$01 + clc + asl + adc #$04 + ; Write 4 to $4016 on Y=even otherwise write 6 to $4016 on Y=odd (For Famicom BASIC Keyboard) + sta CONTROLLER1 +PollControllerLoopSkipKeyboardPoll: + ; $4017 Read (Player 1 and 3) + lda CONTROLLER1 ; 2 + lsr + rol controller1D0, X + lsr + rol controller1D1, X + lsr + rol controller1D2, X + lsr + rol controller1D3, X + lsr + rol controller1D4, X + ; $4017 Read (Player 2, 4, and Famicom BASIC Keyboard) + lda CONTROLLER2 + sta keyboardTmp + lsr + rol controller2D0, X + lsr + rol controller2D1, X + lsr + rol controller2D2, X + lsr + rol controller2D3, X + lsr + rol controller2D4, X +PollControllerEnd: + iny + cpy #$08 + bne PollControllerLoop + ldy #$00 + inx + cpx #CONTROLLER_POLL_LENGTH + bne PollControllerLoop + lda controller1D0 + rts + + +;;;;;;;;;; +;; +;; NES Standard Controller +;; +;;;;;;;;;; + +CheckUpTitle: + lda controller1D0 + and #BUTTON_UP + beq CheckUpTitleDone + lda controller1D0LastFrame + and #(BUTTON_SELECT + BUTTON_UP + BUTTON_DOWN) + bne CheckUpTitleDone + lda $204 + cmp #$B7 + beq CheckUpTitleDone + sec + sbc #$10 + sta $204 +CheckUpTitleDone: + rts + + +CheckDownTitle: + lda controller1D0 + and #BUTTON_DOWN + beq CheckDownTitleDone + lda controller1D0LastFrame + and #(BUTTON_SELECT + BUTTON_UP + BUTTON_DOWN) + bne CheckDownTitleDone + lda $204 + cmp #$C7 + bcs CheckDownTitleDone + clc + adc #$10 + sta $204 +CheckDownTitleDone: + rts + + +CheckSelectTitle: + lda controller1D0 + and #BUTTON_SELECT + beq CheckSelectTitleDone + lda controller1D0LastFrame + and #(BUTTON_SELECT + BUTTON_UP + BUTTON_DOWN) + bne CheckSelectTitleDone + lda $204 + cmp #$B7 + beq CheckSelectNotDownDone + sec + sbc #$10 + sta $204 + jmp CheckSelectTitleDone +CheckSelectNotDownDone: + cmp #$C7 + bcs CheckSelectTitleDone + clc + adc #$10 + sta $204 +CheckSelectTitleDone: + rts + +CheckStartTitle: + lda controller1D0LastFrame + and #BUTTON_START + beq CheckStartTitleContinue + rts +CheckStartTitleContinue: + lda controller1D0 + and #BUTTON_START + bne CheckStartTitleContinueStartPressed + rts +CheckStartTitleContinueStartPressed: + lda $204 + sec + sbc #$A8 + lsr + lsr + lsr + lsr + cmp #$01 + bne CheckStartTitleNotTwitchChat + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda #$23 + sta (drawBuffer), Y + iny + lda #$2F + sta (drawBuffer), Y + iny + lda #$01 + sta (drawBuffer), Y + iny + sty drawBufferOffset + + jsr ClearSprites + jsr SetSwipePixelBottom + + ; Option is Twitch Chat and START press + ; Scroll is top left $2000 + lda #$00 + sta nametable + lda screen + and #%11100000 + ora #SCREEN_TWITCH_CHAT + ora #%00001000 + sta screen + rts +CheckStartTitleNotTwitchChat: + cmp #$00 + bne CheckStartTitleNotSchedule + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda #$22 + sta (drawBuffer), Y + iny + lda #$EF + sta (drawBuffer), Y + iny + lda #$01 + sta (drawBuffer), Y + iny + sty drawBufferOffset + + jsr ClearSprites + jsr SetSwipePixelTop + + lda #$00 + sta nametable + lda screen + and #%11100000 + ora #SCREEN_SCHEDULE + ora #%00001000 + sta screen + rts +CheckStartTitleNotSchedule: + ;TODO + rts + ;TODO + cmp #$02 + bne CheckStartTitleNotExtra + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda #$23 + sta (drawBuffer), Y + iny + lda #$4F + sta (drawBuffer), Y + iny + lda #$01 + sta (drawBuffer), Y + iny + sty drawBufferOffset + + jsr ClearSprites + + jsr SetSwipePixelMiddle + lda #$01 + sta nametable + lda #$FF + sta xscroll + lda #$00 + sta xscrollSlice + lda screen + and #%11100000 + ora #SCREEN_EXTRA + ora #%00001000 + sta screen + rts +CheckStartTitleNotExtra: +CheckStartTitleDone: + rts + +CheckATitle: + lda controller1D0LastFrame + and #BUTTON_A + beq CheckATitleContinue + rts +CheckATitleContinue: + lda controller1D0 + and #BUTTON_A + bne CheckATitleContinueAPressed + rts +CheckATitleContinueAPressed: + lda $204 + sec + sbc #$A8 + lsr + lsr + lsr + lsr + cmp #$01 + bne CheckATitleNotTwitchChat + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda #$23 + sta (drawBuffer), Y + iny + lda #$2F + sta (drawBuffer), Y + iny + lda #$01 + sta (drawBuffer), Y + iny + sty drawBufferOffset + + jsr ClearSprites + jsr SetSwipePixelBottom + + ; Option is Twitch Chat and A press + ; Scroll is top left $2000 + lda #$00 + sta nametable + lda screen + and #%11100000 + ora #SCREEN_TWITCH_CHAT + ora #%00001000 + sta screen + rts +CheckATitleNotTwitchChat: + cmp #$00 + bne CheckATitleNotSchedule + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda #$22 + sta (drawBuffer), Y + iny + lda #$EF + sta (drawBuffer), Y + iny + lda #$01 + sta (drawBuffer), Y + iny + sty drawBufferOffset + + jsr ClearSprites + jsr SetSwipePixelTop + + lda #$00 + sta nametable + lda screen + and #%11100000 + ora #SCREEN_SCHEDULE + ora #%00001000 + sta screen + rts +CheckATitleNotSchedule: + ;TODO + rts + ;TODO + cmp #$02 + bne CheckATitleNotExtra + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda #$23 + sta (drawBuffer), Y + iny + lda #$4F + sta (drawBuffer), Y + iny + lda #$01 + sta (drawBuffer), Y + iny + sty drawBufferOffset + + jsr ClearSprites + + jsr SetSwipePixelMiddle + lda #$01 + sta nametable + lda #$FF + sta xscroll + lda #$00 + sta xscrollSlice + lda screen + and #%11100000 + ora #SCREEN_EXTRA + ora #%00001000 + sta screen + rts +CheckATitleNotExtra: +CheckATitleDone: + rts + +CheckRightSchedule: + lda controller1D0 + and #BUTTON_RIGHT + beq CheckRightScheduleDone + lda controller1D0LastFrame + and #(BUTTON_RIGHT + BUTTON_A + BUTTON_LEFT + BUTTON_B) + bne CheckRightScheduleDone + lda schedule + cmp #SCHEDULE_LAST + beq CheckRightScheduleDone + bcc CheckRightScheduleContinue + lda #SCHEDULE_LAST + sta schedule + jmp CheckRightScheduleDone +CheckRightScheduleContinue: + inc schedule + lda #$01 + sta scheduleChange +CheckRightScheduleDone: + rts + +CheckLeftSchedule: + lda controller1D0 + and #BUTTON_LEFT + beq CheckLeftScheduleDone + lda controller1D0LastFrame + and #(BUTTON_RIGHT + BUTTON_A + BUTTON_LEFT + BUTTON_B) + bne CheckLeftScheduleDone + lda schedule + beq CheckLeftScheduleDone + bpl CheckLeftScheduleContinue + lda #$00 + sta schedule + jmp CheckLeftScheduleDone +CheckLeftScheduleContinue: + dec schedule + lda #$01 + sta scheduleChange +CheckLeftScheduleDone: + rts + +CheckASchedule: + lda controller1D0 + and #BUTTON_A + beq CheckAScheduleDone + lda controller1D0LastFrame + and #(BUTTON_RIGHT + BUTTON_A + BUTTON_LEFT + BUTTON_B) + bne CheckAScheduleDone + lda schedule + cmp #SCHEDULE_LAST + beq CheckAScheduleDone + bcc CheckAScheduleContinue + lda #SCHEDULE_LAST + sta schedule + jmp CheckAScheduleDone +CheckAScheduleContinue: + inc schedule + lda #$01 + sta scheduleChange +CheckAScheduleDone: + rts + +CheckBSchedule: + lda controller1D0 + and #BUTTON_B + beq CheckBScheduleDone + lda controller1D0LastFrame + and #(BUTTON_RIGHT + BUTTON_A + BUTTON_LEFT + BUTTON_B) + bne CheckBScheduleDone + lda schedule + beq CheckBScheduleDone + bpl CheckBScheduleContinue + lda #$00 + sta schedule + jmp CheckBScheduleDone +CheckBScheduleContinue: + dec schedule + lda #$01 + sta scheduleChange +CheckBScheduleDone: + rts + +CheckUpSchedule: + lda controller1D0 + and #BUTTON_UP + beq CheckDownScheduleDone + lda schedule + cmp #SCHEDULE_MAINFRAME + bne CheckUpScheduleDone + lda yscroll + beq CheckUpScheduleDone + dec yscroll + dec yscroll +CheckUpScheduleDone: + rts + +CheckDownSchedule: + lda controller1D0 + and #BUTTON_DOWN + beq CheckDownScheduleDone + lda schedule + cmp #SCHEDULE_MAINFRAME + bne CheckDownScheduleDone + lda yscroll + cmp #$70 + bcs CheckDownScheduleDone + inc yscroll + inc yscroll +CheckDownScheduleDone: + rts + +CheckABStartSelect: + lda controller1D0 + cmp #(BUTTON_A + BUTTON_B + BUTTON_START + BUTTON_SELECT) + bne CheckABStartSelectDone + lda controller1D0LastFrame + and #(BUTTON_A + BUTTON_B + BUTTON_START + BUTTON_SELECT) + cmp #(BUTTON_A + BUTTON_B + BUTTON_START + BUTTON_SELECT) + beq CheckABStartSelectDone + jmp RESET +CheckABStartSelectDone: + rts diff --git a/src/decompress.asm b/src/decompress.asm new file mode 100644 index 0000000..1ccf4da --- /dev/null +++ b/src/decompress.asm @@ -0,0 +1,151 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +DecompressAddr: +DecompressAddrLoop: + lda PPU_STATUS + ldy #$00 + lda (addr), Y + sta PPU_ADDR + sta ppuAddr + jsr IncAddr + lda (addr), Y + sta PPU_ADDR + sta (ppuAddr + 1) + jsr IncAddr +DecompressAddrGetRowByteLoop: + jsr CmpAddrAddrEnd + bne DecompressAddrDone + ; addr not addrEnd + lda (addr), Y + sta tmp + jsr IncAddr + lda tmp + cmp #$01 + beq DecompressAddrGetRowByteLoopIs01 + cmp #$02 + beq DecompressAddrLoop + sta PPU_DATA + jmp DecompressAddrGetRowByteLoop +DecompressAddrGetRowByteLoopIs01: + lda PPU_STATUS + jsr IncPPUAddrOneLineDecompress + lda ppuAddr + sta PPU_ADDR + lda (ppuAddr + 1) + sta PPU_ADDR + jmp DecompressAddrGetRowByteLoop +DecompressAddrDone: + rts + + +IncPPUAddrOneLineDecompress: + lda (ppuAddr + 1) + clc + adc #$20 + sta (ppuAddr + 1) + lda ppuAddr + adc #$00 + sta ppuAddr + rts + + +CmpAddrAddrEnd: + lda (addr + 1) + cmp (addrEnd + 1) + bcc CmpAddrAddrEndLTUpper + bne CmpAddrAddrEndPositive: + lda addr + cmp addrEnd + bcs CmpAddrAddrEndPositive +CmpAddrAddrEndLTUpper: + lda #$00 + rts +CmpAddrAddrEndPositive: + lda #$01 + rts + + +IncAddr: + lda addr + clc + adc #$01 + sta addr + lda (addr + 1) + adc #$00 + sta (addr + 1) + rts + + + +TitleBackgroundMap: + .byte $20, $68 +; #AIRGAP2020 + .byte $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, $10, $11, $12, $01 + .byte $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F, $20, $21, $22 + .byte $02 + .byte $20, $C7 +; Commemorative top + .byte $23, $24, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $25, $26, $01 +; Commemorative middle + .byte $27, $28, $29, $2A, $2B, $2A, $2C, $2D, $2E, $2F, $30, $31, $32, $33, $34, $35, $36, $37, $01 +; Commemorative bottom/NES Cartridge top + .byte $38, $39, $3A, $3B, $3C, $3D, $3E, $3F, $40, $41, $42, $43, $44, $45, $46, $47, $48, $49 + .byte $02 + .byte $21, $29 +; NES Cartridge middle + .byte $06, $4A, $4B, $4C, $27, $28, $4D, $4E, $4F, $50, $51, $52, $53, $37, $01 +; NES Cartridge bottom + .byte $54, $55, $56, $00, $57, $55, $58, $59, $58, $5A, $5B, $5C, $5D, $49 + .byte $02 + .byte $21, $6B +; Airgap Logo Image + .byte $5E, $5F, $5F, $5F, $5F, $5F, $5F, $5F, $5F, $A8, $01 + .byte $60, $61, $62, $62, $62, $62, $62, $62, $63, $64, $01 + .byte $60, $65, $00, $00, $66, $67, $00, $00, $68, $64, $01 + .byte $60, $65, $00, $69, $6A, $6B, $6C, $00, $68, $64, $01 + .byte $60, $6D, $5F, $6E, $6F, $70, $71, $5F, $72, $64, $01 + .byte $60, $73, $74, $75, $76, $76, $77, $78, $79, $64, $01 + .byte $60, $7A, $7B, $7C, $00, $00, $7D, $7E, $7F, $64, $01 + .byte $60, $80, $00, $00, $00, $00, $00, $00, $81, $64, $01 + .byte $60, $82, $83, $83, $83, $83, $83, $83, $84, $64, $01 + .byte $85, $76, $76, $76, $76, $76, $76, $76, $76, $86 + .byte $02 + + .byte $23, $02 + .byte $93, $94, $95, $96, $97, $98, $99, $9A, $9B, $9C, $9D, $9E, $9F, $01 + .byte $A0, $A1, $A2, $A3, $A4 + + .byte $02 +; TALK SCHEDULE + .byte $22, $F1 + .byte $87, $88, $89, $8A, $00, $8B, $8C, $8D, $8E, $8F, $90, $89, $8E, $01 + .byte $01 +; TWITCH CHAT + .byte $87, $91, $92, $87, $8C, $8D, $00, $8C, $8D, $88, $87, $01 + ;.byte $01 + ;.byte $92, $A5, $8B, $87, $A6, $90, $8C, $87, $92, $A7, $A5, $8B +TitleBackgroundMapEnd: diff --git a/src/defs.asm b/src/defs.asm new file mode 100644 index 0000000..894245b --- /dev/null +++ b/src/defs.asm @@ -0,0 +1,51 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +BUTTON_A = 1 << 7 +BUTTON_B = 1 << 6 +BUTTON_SELECT = 1 << 5 +BUTTON_START = 1 << 4 +BUTTON_UP = 1 << 3 +BUTTON_DOWN = 1 << 2 +BUTTON_LEFT = 1 << 1 +BUTTON_RIGHT = 1 << 0 + +PPU_CTRL = $2000 +PPU_MASK = $2001 +PPU_STATUS = $2002 +PPU_OAM_ADDR = $2003 +PPU_OAM_DATA = $2004 +PPU_SCROLL = $2005 +PPU_ADDR = $2006 +PPU_DATA = $2007 + +APU_DMC = $4010 +OAM_DMA = $4014 +APU_FRAME_COUNTER = $4017 + +CALLBACK = $FFFA + +MIRROR_V = 0 +MIRROR_H = 1 diff --git a/src/draw.asm b/src/draw.asm new file mode 100644 index 0000000..f975c85 --- /dev/null +++ b/src/draw.asm @@ -0,0 +1,518 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +ResetScroll: + ; Scroll X position + lda xscroll + sta PPU_SCROLL + ; Scroll Y position + lda yscroll + sta PPU_SCROLL + jsr EnableNMI + rts + + +Draw: + lda #%00011110 + ora emphasis + sta PPU_MASK + rts + + +DisableNMI: + lda #$00 + sta PPU_CTRL + rts + + +EnableNMI: + lda #%10000000 + ora nametable + ora patterns + sta PPU_CTRL + rts + + +Blank: + lda #%00000110 + ora emphasis + sta PPU_MASK + jsr DisableNMI + rts + + +SetTwitchChatPalette: + lda PPU_STATUS + lda #$3F + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + ldx #$08 +SetTwitchChatPaletteLoop: + lda #$0F + sta PPU_DATA + sta PPU_DATA + lda #$29 + sta PPU_DATA + lda #$30 + sta PPU_DATA + dex + bne SetTwitchChatPaletteLoop + rts + + +SetBlackPalette: + lda #$3F + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + ldx #$08 + lda #$0F +SetBlackPaletteLoop: + sta PPU_DATA + sta PPU_DATA + sta PPU_DATA + sta PPU_DATA + dex + bne SetBlackPaletteLoop + rts + + +ClearPPURAM: + lda #$20 + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + ldy #$10 + ldx #$00 + txa +ClearPPURAMLoop: + sta PPU_DATA + dex + bne ClearPPURAMLoop + ldx #$00 + dey + bne ClearPPURAMLoop + rts + + +ClearScreen: + ldx #$00 + lda #$20 + sta addr + jmp ClearScreenStartNametableLoop +ClearScreenLoop: + lda addr + clc + adc #$04 + sta addr +ClearScreenStartNametableLoop: + lda PPU_STATUS + lda addr + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + ldx #$1E + ldy #$20 + lda #$00 +ClearScreenNametableLoop: + sta PPU_DATA + dex + bne ClearScreenNametableLoop + ldx #$1E + dey + bne ClearScreenNametableLoop + lda addr + cmp #$2C + bne ClearScreenLoop + rts + + +DrawChatByte: + lda chatByte + cmp #$20 + bcc DrawChatByteNotPrintable + jsr DrawPrintableChatByte + lda (ppuAddr + 1) + and #$1F + cmp #$1D + bne DrawChatBytePrintableContinue + jsr IncPPUAddrOneLine + jsr IncPPUAddr + jsr IncPPUAddr + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda ppuAddr + sta (drawBuffer), Y + iny + lda (ppuAddr + 1) + sta (drawBuffer), Y + iny + sty drawBufferOffset + inc newLine + jsr AdjustYScrollNametable + rts +DrawChatBytePrintableContinue: + jsr IncPPUAddr + rts +DrawChatByteNotPrintable: + cmp #$0A + bne DrawChatByteDone + jsr IncPPUAddrOneLine + jsr IncPPUAddr + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda ppuAddr + sta (drawBuffer), Y + iny + lda (ppuAddr + 1) + sta (drawBuffer), Y + iny + sty drawBufferOffset + inc newLine + jsr AdjustYScrollNametable +DrawChatByteDone: + rts + + +DrawPrintableChatByte: + ldy drawBufferOffset + lda chatByte + sta (drawBuffer), Y + iny + sty drawBufferOffset + rts + + +ClearLines: + lda newLine + beq ClearLinesDone + lda ppuAddr + sta ppuAddrTmp + lda (ppuAddr + 1) + sta (ppuAddrTmp + 1) + + lda #$03 + sbc newLine + tay +ClearLinesIncPPUAddrTmpLoop: + jsr IncPPUAddrOneLine + dey + bne ClearLinesIncPPUAddrTmpLoop + jsr IncPPUAddrOneLine + jsr IncPPUAddrOneLine + jsr IncPPUAddrOneLine + jsr IncPPUAddrOneLine + jsr IncPPUAddrOneLine + + jsr DrawClearLines + + lda ppuAddrTmp + sta ppuAddr + lda (ppuAddrTmp + 1) + sta (ppuAddr + 1) +ClearLinesDone: + rts + + +DrawClearLines: + lda newLine + sta tmp +DrawClearLinesLoop: + jsr IncPPUAddrOneLine + jsr IncPPUAddr + ldy drawBufferOffset + lda #$8E + sta (drawBuffer), Y + iny + lda ppuAddr + sta (drawBuffer), Y + iny + lda (ppuAddr + 1) + sta (drawBuffer), Y + iny + sty drawBufferOffset + lda newLine + cmp #$01 + bne DrawClearLinesLoopNotLastLoop + ; is last line to clear + lda tmp + cmp #$03 + bne DrawClearLinesLoopNotLastLoop + jsr Draw3Spaces + rts +DrawClearLinesLoopNotLastLoop: + jsr Draw29Spaces + dec newLine + bne DrawClearLinesLoop + rts + + +Draw29Spaces: + ldx #29 + ldy drawBufferOffset + lda #$20 +Draw29SpacesLoop: + sta (drawBuffer), Y + iny + dex + bne Draw29SpacesLoop + sty drawBufferOffset + rts + + +Draw3Spaces: + ldx #03 + ldy drawBufferOffset + lda #$20 +Draw3SpacesLoop: + sta (drawBuffer), Y + iny + dex + bne Draw3SpacesLoop + sty drawBufferOffset + rts + + +IncPPUAddr: + lda (ppuAddr + 1) + clc + adc #$01 + sta (ppuAddr + 1) + lda ppuAddr + adc #$00 + sta ppuAddr + jsr AdjustPPUAddr + rts + + +IncPPUAddrOneLine: + lda (ppuAddr + 1) + clc + adc #$20 + sta (ppuAddr + 1) + lda ppuAddr + adc #$00 + sta ppuAddr + jsr AdjustPPUAddr + lda (ppuAddr + 1) + and #%11100000 + sta (ppuAddr + 1) + rts + + +AdjustYScrollNametable: + lda (ppuAddr + 1) + and #%11100000 + rol + sta ppuAddrRow + lda ppuAddr + and #%00000011 + ora ppuAddrRow + rol + rol + rol + sta ppuAddrRow + lda enableYScroll + bne AdjustYScrollNametableGetBaseNametable + lda ppuAddrRow + cmp #CHAT_LINE_BEFORE_Y_SCROLL + bcc AdjustYScrollNametableDone + inc enableYScroll +AdjustYScrollNametableGetBaseNametable: + lda ppuAddr + cmp #$28 + bcc AdjustYScrollNametableNotNametable3 + ; Nametable is 3 + lda ppuAddrRow + clc + adc #30 + sta ppuAddrRow +AdjustYScrollNametableNotNametable3: + + lda ppuAddrRow + adc #$01 + sec + sbc #CHAT_LINE_BEFORE_Y_SCROLL + bcs AdjustNametableFromPPUAddrRow + adc #60 +AdjustNametableFromPPUAddrRow: + sta ppuAddrRow + lda #$00 + sta nametable + lda ppuAddrRow + cmp #30 + bcc AdjustYScrollFromPPUAddrRow + sec + sbc #30 + sta ppuAddrRow + lda #$02 + sta nametable +AdjustYScrollFromPPUAddrRow: + lda ppuAddrRow + asl + asl + asl + sta yscroll +AdjustYScrollNametableDone: + rts + + +AdjustPPUAddr: + lda ppuAddr + cmp #$28 + bcs AdjustPPUAddrNametable3 + ; PPU Addr within first Nametable ($2000) + lda ppuAddr + cmp #$23 + bcc AdjustPPUAddrDone + bne AdjustPPUAddrAdd440 + ; PPU Addr is $23XX + lda (ppuAddr + 1) + cmp #$C0 + bcc AdjustPPUAddrDone +AdjustPPUAddrAdd440: + lda (ppuAddr + 1) + clc + adc #$40 + sta (ppuAddr + 1) + lda ppuAddr + adc #$04 + sta ppuAddr + rts +AdjustPPUAddrNametable3: + ; PPU Addr within third Nametable ($2800) + lda ppuAddr + cmp #$2B + bcc AdjustPPUAddrDone + ; ppuAddr GTE $2BXX + bne AdjustPPUAddrSubBC0 + ; PPU Addr is $2BXX + lda (ppuAddr + 1) + cmp #$C0 + bcc AdjustPPUAddrDone +AdjustPPUAddrSubBC0: + lda (ppuAddr + 1) + sec + sbc #$C0 + sta (ppuAddr + 1) + lda ppuAddr + sbc #$0B + sta ppuAddr +AdjustPPUAddrDone: + rts + + +DrawPreviousFrame: + ldy #$00 +DrawPreviousFrameLoop: + lda PPU_STATUS + lda (drawBuffer), Y + iny + cmp #$8F + beq DrawPreviousFrameDone + cmp #$8E + beq DrawPreviousFrameLoop + sta PPU_ADDR + lda (drawBuffer), Y + iny + sta PPU_ADDR +DrawPreviousFrameLoopContentLoop: + lda (drawBuffer), Y + iny + cmp #$8E + beq DrawPreviousFrameLoop + ; Not #$8E + cmp #$8F + beq DrawPreviousFrameDone + ; Not #$8F + sta PPU_DATA + jmp DrawPreviousFrameLoopContentLoop +DrawPreviousFrameDone: + jsr InitializeDrawBuffer + rts + + +InitializeDrawBuffer: + ldy #$00 + sty drawBufferOffset + lda #$8F + sta (drawBuffer), Y + rts + + +ClearAttributes: + lda PPU_STATUS + lda #$23 + sta PPU_ADDR + lda #$C0 + sta PPU_ADDR + jsr ClearAttributesDraw + lda PPU_STATUS + lda #$27 + sta PPU_ADDR + lda #$C0 + sta PPU_ADDR + jsr ClearAttributesDraw + lda PPU_STATUS + lda #$2B + sta PPU_ADDR + lda #$C0 + sta PPU_ADDR + jsr ClearAttributesDraw + lda PPU_STATUS + lda #$2F + sta PPU_ADDR + lda #$C0 + sta PPU_ADDR + jsr ClearAttributesDraw + rts + + +ClearAttributesDraw: + ldy #$08 + ldx #15 + lda #$00 +ClearAttributesDrawLoop: + sta PPU_DATA + dex + bne ClearAttributesDrawLoop + ldx #15 + dey + bne ClearAttributesDrawLoop + rts + + +EndDrawBuffer: + ldy drawBufferOffset + lda #$8F + sta (drawBuffer), Y + iny + sty drawBufferOffset + rts diff --git a/src/graphics/ascii.bin b/src/graphics/ascii.bin new file mode 100644 index 0000000..ed55ce0 Binary files /dev/null and b/src/graphics/ascii.bin differ diff --git a/src/graphics/bar-top.bin b/src/graphics/bar-top.bin new file mode 100644 index 0000000..d2f7859 Binary files /dev/null and b/src/graphics/bar-top.bin differ diff --git a/src/graphics/schedule/00.bin b/src/graphics/schedule/00.bin new file mode 100644 index 0000000..b3cf90b Binary files /dev/null and b/src/graphics/schedule/00.bin differ diff --git a/src/graphics/schedule/01.bin b/src/graphics/schedule/01.bin new file mode 100644 index 0000000..3a67713 Binary files /dev/null and b/src/graphics/schedule/01.bin differ diff --git a/src/graphics/schedule/02.bin b/src/graphics/schedule/02.bin new file mode 100644 index 0000000..9d63b3b Binary files /dev/null and b/src/graphics/schedule/02.bin differ diff --git a/src/graphics/schedule/03.bin b/src/graphics/schedule/03.bin new file mode 100644 index 0000000..088f0bc Binary files /dev/null and b/src/graphics/schedule/03.bin differ diff --git a/src/graphics/schedule/04.bin b/src/graphics/schedule/04.bin new file mode 100644 index 0000000..74d0bd5 Binary files /dev/null and b/src/graphics/schedule/04.bin differ diff --git a/src/graphics/schedule/05.bin b/src/graphics/schedule/05.bin new file mode 100644 index 0000000..7a055ed Binary files /dev/null and b/src/graphics/schedule/05.bin differ diff --git a/src/graphics/schedule/06.bin b/src/graphics/schedule/06.bin new file mode 100644 index 0000000..6605361 Binary files /dev/null and b/src/graphics/schedule/06.bin differ diff --git a/src/graphics/schedule/07.bin b/src/graphics/schedule/07.bin new file mode 100644 index 0000000..8eaa708 Binary files /dev/null and b/src/graphics/schedule/07.bin differ diff --git a/src/graphics/schedule/08.bin b/src/graphics/schedule/08.bin new file mode 100644 index 0000000..8b88f16 Binary files /dev/null and b/src/graphics/schedule/08.bin differ diff --git a/src/graphics/schedule/09.bin b/src/graphics/schedule/09.bin new file mode 100644 index 0000000..290b9ab Binary files /dev/null and b/src/graphics/schedule/09.bin differ diff --git a/src/graphics/schedule/0A.bin b/src/graphics/schedule/0A.bin new file mode 100644 index 0000000..a702896 Binary files /dev/null and b/src/graphics/schedule/0A.bin differ diff --git a/src/graphics/schedule/0B.bin b/src/graphics/schedule/0B.bin new file mode 100644 index 0000000..923c033 Binary files /dev/null and b/src/graphics/schedule/0B.bin differ diff --git a/src/graphics/schedule/0C.bin b/src/graphics/schedule/0C.bin new file mode 100644 index 0000000..c3cdc7f Binary files /dev/null and b/src/graphics/schedule/0C.bin differ diff --git a/src/graphics/schedule/0D.bin b/src/graphics/schedule/0D.bin new file mode 100644 index 0000000..b46790f Binary files /dev/null and b/src/graphics/schedule/0D.bin differ diff --git a/src/graphics/schedule/0E.bin b/src/graphics/schedule/0E.bin new file mode 100644 index 0000000..e14380c Binary files /dev/null and b/src/graphics/schedule/0E.bin differ diff --git a/src/graphics/schedule/0F.bin b/src/graphics/schedule/0F.bin new file mode 100644 index 0000000..5bfc6b7 Binary files /dev/null and b/src/graphics/schedule/0F.bin differ diff --git a/src/graphics/schedule/10.bin b/src/graphics/schedule/10.bin new file mode 100644 index 0000000..582623c Binary files /dev/null and b/src/graphics/schedule/10.bin differ diff --git a/src/graphics/schedule/11.bin b/src/graphics/schedule/11.bin new file mode 100644 index 0000000..fe46205 Binary files /dev/null and b/src/graphics/schedule/11.bin differ diff --git a/src/graphics/schedule/12.bin b/src/graphics/schedule/12.bin new file mode 100644 index 0000000..2a74afa Binary files /dev/null and b/src/graphics/schedule/12.bin differ diff --git a/src/graphics/schedule/13.bin b/src/graphics/schedule/13.bin new file mode 100644 index 0000000..f02d52b Binary files /dev/null and b/src/graphics/schedule/13.bin differ diff --git a/src/graphics/schedule/14.bin b/src/graphics/schedule/14.bin new file mode 100644 index 0000000..619cf4b Binary files /dev/null and b/src/graphics/schedule/14.bin differ diff --git a/src/graphics/schedule/15.bin b/src/graphics/schedule/15.bin new file mode 100644 index 0000000..0d265a5 Binary files /dev/null and b/src/graphics/schedule/15.bin differ diff --git a/src/graphics/title-tileset.chr b/src/graphics/title-tileset.chr new file mode 100644 index 0000000..66ccee8 Binary files /dev/null and b/src/graphics/title-tileset.chr differ diff --git a/src/graphics/twitch-chat-tileset.chr b/src/graphics/twitch-chat-tileset.chr new file mode 100644 index 0000000..ee98f65 Binary files /dev/null and b/src/graphics/twitch-chat-tileset.chr differ diff --git a/src/mmc1.asm b/src/mmc1.asm new file mode 100644 index 0000000..3d20f48 --- /dev/null +++ b/src/mmc1.asm @@ -0,0 +1,88 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +MIRRORING_V = $02 +MIRRORING_H = $03 + +;; Expects A to be the CHR ROM Bank +SetMMC1CHRBank: + sta $A000 + lsr + sta $A000 + lsr + sta $A000 + lsr + sta $A000 + lsr + sta $A000 + rts + +SetMMC1CHRBank2: + sta $C000 + lsr + sta $C000 + lsr + sta $C000 + lsr + sta $C000 + lsr + sta $C000 + rts + + +SetMMC1PRGBank: + lda chatBank + sta $E000 + lsr + sta $E000 + lsr + sta $E000 + lsr + sta $E000 + lsr + sta $E000 + rts + + +MMC1Initialize: + lda chrSwitchSize + and #%00000001 + asl + asl + asl + asl + ora #%00001100 + ora mirroring + sta $8000 + lsr + sta $8000 + lsr + sta $8000 + lsr + sta $8000 + lsr + sta $8000 + rts diff --git a/src/prg.asm b/src/prg.asm new file mode 100644 index 0000000..22c0ca0 --- /dev/null +++ b/src/prg.asm @@ -0,0 +1,190 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +RESET: + sei + cld + ldx #$40 + stx APU_FRAME_COUNTER + ldx #$FF + txs + inx + lda #%00000110 + sta PPU_MASK + stx PPU_CTRL + stx APU_DMC + + stx chatBank + jsr SetMMC1PRGBank + +InitialVWait: + lda regionTmp + sta region + ldy #$00 + lda PPU_STATUS + bpl InitialVWait +InitialVWait2: + inx + bne InitialVWait2NotIncY + iny +InitialVWait2NotIncY: + lda PPU_STATUS + bpl InitialVWait2 + ldx #$00 + cpy #$09 + bne NotNTSC + lda #60 + inx + jmp InitialVWaitDone +NotNTSC: + lda #50 + cpy #$0A + bne NotPAL + jmp InitialVWaitDone +NotPAL: + cpy #$0B + bne NotDendy + ldx #$02 + jmp InitialVWaitDone +NotDendy: + ldx #$03 +InitialVWaitDone: + sta fps + stx regionTmp + cpx region + bne InitialVWait + + +InitializeRAM: + ldx #$00 +InitializeRAMLoop: + lda #$00 + cpx #fps + beq InitializeRAMSkipZeroPage + cpx #region + beq InitializeRAMSkipZeroPage + sta $0000, x +InitializeRAMSkipZeroPage: + sta $0100, x + sta $0300, x + sta $0400, x + sta $0500, x + sta $0600, x + sta $0700, x + lda #$FE + sta $0200, x + inx + bne InitializeRAMLoop + + lda #(SCREEN_TITLE) + sta screen + ora #%1110000 + sta screen + + lda #(BUTTON_A + BUTTON_B + BUTTON_START + BUTTON_SELECT) + sta controller1D0 + sta controller1D0LastFrame + + jsr InitializeScreen + + +Forever: + jmp Forever + + +NMI: + lda #$00 + sta PPU_OAM_ADDR + lda #$02 + sta OAM_DMA + lda PPU_STATUS + jsr HandleScheduleChange + jsr DrawPreviousFrame + jsr Draw + jsr ResetScroll + jsr InitializeScreen + lda allowUpdate + beq NMIDone + jsr Update + jsr UpdateScheduleChange +NMIDone: + jsr EndDrawBuffer + rti + + +Update: + jsr PollController + jsr CheckABStartSelect + lda screen + and #%00000111 + cmp #SCREEN_TWITCH_CHAT + bne UpdateNotTwitchChat + ; Screen IS Twitch Chat + jsr UpdateTwitchChat + rts +UpdateNotTwitchChat: + cmp #SCREEN_SCHEDULE + bne UpdateNotSchedule + ; Screen IS schedule + jsr UpdateSchedule + rts +UpdateNotSchedule: +UpdateCatchallTitle: + ; Screen is Catchall, so show Title + jsr UpdateTitle + rts + + +UpdateTitle: + jsr CheckStartTitle + jsr CheckATitle + jsr CheckDownTitle + jsr CheckUpTitle + jsr CheckSelectTitle + rts + + +UpdateTwitchChat: + inc frames + lda frames + and #$01 + beq UpdateTwitchChatHandleClearFrame + jsr HandleChatFrame + rts +UpdateTwitchChatHandleClearFrame: + jsr ClearLines + rts + +UpdateSchedule: + inc frames + jsr DrawArrowSprites + jsr CheckASchedule + jsr CheckBSchedule + jsr CheckRightSchedule + jsr CheckLeftSchedule + jsr CheckUpSchedule + jsr CheckDownSchedule + rts diff --git a/src/ram.asm b/src/ram.asm new file mode 100644 index 0000000..bbb9446 --- /dev/null +++ b/src/ram.asm @@ -0,0 +1,73 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +.enum $0000 +Variables: + fps dsb 1 + region dsb 1 + regionTmp dsb 1 + screen dsb 1 + allowUpdate dsb 1 + addr dsb 2 + addrEnd dsb 2 + chatData dsb 32 + + chatBank dsb 1 + zeroFrames dsb 3 + + chatAddr dsb 2 + tmp dsb 1 + + ppuAddr dsb 2 + ppuAddrTmp dsb 2 + ppuAddrRow dsb 1 + enableYScroll dsb 1 + yscroll dsb 1 + xscroll dsb 1 + nametable dsb 1 + yscrollSlice dsb 1 + xscrollSlice dsb 1 + nametableSlice dsb 1 + patterns dsb 1 + mirroring dsb 1 + chrSwitchSize dsb 1 + emphasis dsb 1 + newLine dsb 1 + enableYScrollTitle dsb 1 + schedule dsb 1 + scheduleChange dsb 1 +.ende + +.enum $0300 +DrawBufferVariables: + drawBufferOffset dsb 1 + drawBufferOffsetTmp dsb 1 + drawBuffer dsb 200 + draw dsb 1 +.ende + +.enum $0600 + frames dsb 2 +.ende diff --git a/src/schedule-text.asm b/src/schedule-text.asm new file mode 100644 index 0000000..93214ca --- /dev/null +++ b/src/schedule-text.asm @@ -0,0 +1,604 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +ScheduleStartOffsets: + .byte #<(PresentationsStart), #>(PresentationsStart) + .byte #<(Ch0pp3dStart), #>(Ch0pp3dStart) + .byte #<(Twitch2ShStart), #>(Twitch2ShStart) + .byte #<(StartStart), #>(StartStart) + .byte #<(IncubationStart), #>(IncubationStart) + .byte #<(LuigibloodStart), #>(LuigibloodStart) + .byte #<(MainframeStart), #>(MainframeStart) + .byte #<(ReidStart), #>(ReidStart) + .byte #<(NahamsecStart), #>(NahamsecStart) + .byte #<(IlyaStart), #>(IlyaStart) + .byte #<(MGStart), #>(MGStart) + .byte #<(Twitch2ShellStart), #>(Twitch2ShellStart) + .byte #<(NetspookyStart), #>(NetspookyStart) + .byte #<(CaseyStart), #>(CaseyStart) + .byte #<(SilvioStart), #>(SilvioStart) + .byte #<(SyedStart), #>(SyedStart) + .byte #<(SnyffStart), #>(SnyffStart) + .byte #<(OutbreakStart), #>(OutbreakStart) + .byte #<(YTCrackerStart), #>(YTCrackerStart) + +ScheduleEndOffsets: + .byte #<(PresentationsEnd), #>(PresentationsEnd) + .byte #<(Ch0pp3dEnd), #>(Ch0pp3dEnd) + .byte #<(Twitch2ShEnd), #>(Twitch2ShEnd) + .byte #<(StartEnd), #>(StartEnd) + .byte #<(IncubationEnd), #>(IncubationEnd) + .byte #<(LuigibloodEnd), #>(LuigibloodEnd) + .byte #<(MainframeEnd), #>(MainframeEnd) + .byte #<(ReidEnd), #>(ReidEnd) + .byte #<(NahamsecEnd), #>(NahamsecEnd) + .byte #<(IlyaEnd), #>(IlyaEnd) + .byte #<(MGEnd), #>(MGEnd) + .byte #<(Twitch2ShellEnd), #>(Twitch2ShellEnd) + .byte #<(NetspookyEnd), #>(NetspookyEnd) + .byte #<(CaseyEnd), #>(CaseyEnd) + .byte #<(SilvioEnd), #>(SilvioEnd) + .byte #<(SyedEnd), #>(SyedEnd) + .byte #<(SnyffEnd), #>(SnyffEnd) + .byte #<(OutbreakEnd), #>(OutbreakEnd) + .byte #<(YTCrackerEnd), #>(YTCrackerEnd) + +ScheduleMMC1CHRBank: + .byte $04, $04, $04 + .byte $04, $04, $04 + .byte $05 + .byte $06, $06, $06 + .byte $07, $07, $07 + .byte $08, $08, $08 + .byte $09, $09, $09 + +StartStart: + .byte $23, $C8 + .byte %01000100, %01000101, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000 + .byte %00000100, %00000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, $02 + .byte $3F, $00 + .byte $0F, $08, $18, $30 + .byte $0F, $08, $1C, $2C, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $80, $81, $82, $83, $84, $85, $08, $01 + .byte $07, $86, $87, $88, $89, $8A, $8B, $08, $01 + .byte $07, $8C, $8D, $8E, $8F, $90, $91, $08, $01 + .byte $07, $92, $93, $94, $95, $96, $97, $08, $01 + .byte $07, $98, $99, $9A, $9B, $9C, $9D, $08, $01 + .byte $07, $9E, $9F, $A0, $A1, $A2, $A3, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "11:30-12:00", $02 + .byte $21, $62 + .byte "THE GAP IS CROSSED", $01, $01 + .byte "THE STREAM WILL START AT", $01 + .byte "11:30AM. THE TEXT CHAT WILL", $01 + .byte "BE SPICY AND THE EVENTS WILL", $01 + .byte "BEGIN." +StartEnd: + +IncubationStart: + .byte $23, $C8 + .byte %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000 + .byte %00000000, %00000101, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, $02 + .byte $3F, $00 + .byte $0F, $16, $27, $30 + .byte $0F, $30, $11, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $A4, $A5, $A6, $A7, $A8, $A9, $08, $01 + .byte $07, $AA, $AB, $AC, $AD, $AE, $AF, $08, $01 + .byte $07, $B0, $B1, $B2, $B3, $B4, $B5, $08, $01 + .byte $07, $B6, $B7, $B8, $B9, $BA, $BB, $08, $01 + .byte $07, $BC, $BD, $BE, $BF, $C0, $C1, $08, $01 + .byte $07, $C2, $C3, $C4, $C5, $C6, $C7, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "12:00-12:30", $02 + .byte $21, $62 + .byte "INCUBATION PERIOD", $01, $01 + .byte "GUESTS WILL BE GR33TZ'D WITH", $01 + .byte "A GENERAL CHECKUP. ALL THE", $01 + .byte "USUAL DISCLAIMERS AND A FEW", $01 + .byte "WORDS FROM THE THUGCROWD", $01 + .byte "HOSTS." +IncubationEnd: + +LuigibloodStart: + .byte $3F, $00 + .byte $0F, $11, $28, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $C8, $C9, $CA, $CB, $CC, $CD, $08, $01 + .byte $07, $CE, $CF, $D0, $D1, $D2, $D3, $08, $01 + .byte $07, $D4, $D5, $D6, $D7, $D8, $D9, $08, $01 + .byte $07, $DA, $DB, $DC, $DD, $DE, $DF, $08, $01 + .byte $07, $E0, $E1, $E2, $E3, $E4, $E5, $08, $01 + .byte $07, $E6, $E7, $E8, $E9, $EA, $EB, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "12:30-13:00", $02 + .byte $21, $62 + .byte "LUIGIBLOOD", $01, $01 + .byte "SATELLAVIEW REVERSE", $01 + .byte "ENGINEERING", $01, $01 + .byte "COME HEAR THE TALE OF", $01 + .byte "REVERSE ENGINEERING THE", $01 + .byte "SATELLAVIEW, A SATELLITE", $01 + .byte "ADD-ON FOR THE SUPER FAMICOM", $01 + .byte "TO DOWNLOAD GAMES. YOU MAY", $01 + .byte "HAVE NEVER HEARD OF IT, BUT", $01 + .byte "COME SEE HOW IT WORKS!" +LuigibloodEnd: + +MainframeStart: + .byte $23, $F0 + .byte %10000000, %10100000, %10000000, %10100000, %11000000, %11110000, %00000000, %00000000 + .byte %00001000, %00001010, %00001000, %00001010, %00001100, %00001111, %00000000, %00000000, $02 + .byte $2B, $C0 + .byte %00001000, %00001010, %00001000, %00001010, %00001100, %00001111, %00000000, %00000000 + .byte %01000100, %01010101, %00000000, %00000000, %11001100, %11111111, %00000000, %00000000 + .byte %00000100, %00000101, %00000000, %00000000, %00001100, %00001111, %00000000, %00000000, $02 + .byte $3F, $00 + .byte $0F, $2A, $16, $30 + .byte $0F, $11, $27, $30 + .byte $0F, $0A, $1A, $2A + .byte $0F, $08, $27, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $00, $00, $00, $00, $00, $00, $08, $01 + .byte $07, $00, $00, $00, $00, $00, $00, $08, $01 + .byte $07, $50, $00, $51, $52, $00, $53, $08, $01 + .byte $07, $00, $00, $00, $00, $00, $54, $08, $01 + .byte $07, $55, $00, $56, $57, $00, $58, $08, $01 + .byte $07, $59, $00, $5A, $5B, $00, $5C, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte $21, $23, $2A, $20, $20, $1D, $21, $24, $2A, $20, $20, $02 + .byte $21, $62 + .byte $3D, $31, $39, $3E, $36, $42, $31, $3D, $35, $10, $38, $31, $33, $3B, $35, $42, $10, $43, $3F, $33, $39, $35, $44, $49, $01 + .byte $40, $31, $3E, $35, $3C, $01, $01 + .byte $3A, $3F, $39, $3E, $10, $44, $38, $35, $10, $3D, $31, $39, $3E, $36, $42, $31, $3D, $35, $10, $43, $3F, $33, $39, $35, $44, $49, $01 + .byte $40, $42, $35, $46, $39, $3F, $45, $43, $3C, $49, $10, $3F, $40, $35, $42, $31, $44, $39, $3E, $37, $10, $39, $3E, $01 + .byte $43, $35, $33, $42, $35, $44, $10, $44, $3F, $10, $36, $45, $42, $44, $38, $35, $42, $10, $44, $38, $35, $10, $43, $44, $45, $34, $49, $01 + .byte $31, $3E, $34, $10, $31, $34, $46, $31, $3E, $33, $35, $3D, $35, $3E, $44, $10, $3F, $36, $10, $3D, $31, $39, $3E, $36, $42, $31, $3D, $35, $01 + .byte $43, $35, $33, $45, $42, $39, $44, $49, $10, $31, $42, $3F, $45, $3E, $34, $10, $44, $38, $35, $10, $47, $3F, $42, $3C, $34, $11, $01, $01 + .byte $30, $3D, $31, $39, $3E, $36, $42, $31, $3D, $35, $34, $27, $26, $27, $10, $10, $10, $30, $3E, $3F, $37, $3F, $3E, $3F, $43, $31, $01 + .byte $30, $32, $39, $37, $35, $3E, $34, $39, $31, $3E, $43, $3D, $31, $3C, $3C, $43, $01 + .byte $30, $47, $39, $4A, $31, $42, $34, $3F, $36, $4A, $3F, $43, $10, $10, $10, $10, $10, $30, $4A, $32, $39, $44, $23, $21, $01 + .byte $30, $33, $38, $21, $3B, $40, $35, $35, $02 + .byte $23, $21 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $04, $05, $05, $05, $05, $05, $05, $06, $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $5D, $5E, $5F, $60, $61, $62, $08, $07, $00, $00, $00, $00, $00, $00, $08, $07, $0F, $0F, $0F, $95, $96, $0F, $08, $01 + .byte $07, $63, $64, $65, $66, $67, $68, $08, $07, $00, $81, $82, $83, $84, $00, $08, $07, $0F, $0F, $97, $0E, $0E, $98, $08, $01 + .byte $07, $69, $6A, $6B, $6C, $6D, $6E, $08, $07, $85, $86, $87, $88, $89, $8A, $08, $07, $0F, $99, $9A, $9B, $9C, $9D, $08, $01 + .byte $07, $6F, $70, $71, $72, $73, $74, $08, $07, $8B, $8C, $8D, $8E, $8F, $90, $08, $07, $0F, $9E, $9F, $A0, $A1, $A2, $08, $02 + .byte $28, $01 + .byte $07, $75, $76, $77, $78, $79, $7A, $08, $07, $00, $91, $92, $93, $94, $00, $08, $07, $A3, $A4, $A5, $A6, $A7, $A8, $08, $01 + .byte $07, $7B, $7C, $7D, $7E, $7F, $80, $08, $07, $00, $00, $00, $00, $00, $00, $08, $07, $00, $00, $A9, $AA, $AB, $AC, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $01 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $04, $05, $05, $05, $05, $05, $05, $06, $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $0F, $0F, $0F, $AD, $AE, $0F, $08, $07, $C5, $C6, $C7, $C8, $C9, $CA, $08, $07, $0F, $E3, $E4, $E5, $0F, $0F, $08, $01 + .byte $07, $0F, $AF, $B0, $B1, $B2, $B3, $08, $07, $CB, $CC, $CD, $CE, $CF, $D0, $08, $07, $0F, $E6, $E7, $E8, $E9, $0F, $08, $01 + .byte $07, $B4, $B5, $B6, $B7, $B8, $B9, $08, $07, $D1, $D2, $D3, $D4, $D5, $D6, $08, $07, $0F, $EA, $EB, $EC, $ED, $0F, $08, $01 + .byte $07, $0F, $BA, $BB, $BC, $BD, $BE, $08, $07, $00, $D7, $D8, $D9, $DA, $00, $08, $07, $0F, $EE, $EF, $F0, $F1, $0F, $08, $01 + .byte $07, $0F, $0F, $BF, $C0, $C1, $0F, $08, $07, $DB, $DC, $DD, $DE, $DF, $00, $08, $07, $F2, $F3, $F4, $F5, $F6, $F7, $08, $01 + .byte $07, $0F, $0F, $C2, $C3, $C4, $0F, $08, $07, $00, $E0, $E1, $00, $E2, $00, $08, $07, $0D, $F8, $0F, $0F, $F9, $FA, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B +MainframeEnd: + +ReidStart: + .byte $3F, $00 + .byte $0F, $08, $27, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $80, $81, $82, $83, $84, $85, $08, $01 + .byte $07, $86, $87, $88, $89, $8A, $8B, $08, $01 + .byte $07, $8C, $8D, $8E, $8F, $90, $91, $08, $01 + .byte $07, $92, $93, $94, $95, $96, $97, $08, $01 + .byte $07, $98, $99, $9A, $9B, $9C, $9D, $08, $01 + .byte $07, $9E, $9F, $A0, $A1, $A2, $A3, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "14:00-14:30", $02 + .byte $21, $62 + .byte "REID WIGHTMAN", $01, $01 + .byte "SWITCHES GET ROOT CANALS", $01, $01 + .byte "COME EXAMINE A TYPICAL LAYER", $01 + .byte "2 SWITCH, WITHOUT MANY", $01 + .byte "FEATURES, IDENTIFY A 'ROOT'", $01 + .byte "LEVEL VULNERABILITY, AND SEE", $01 + .byte "WHAT WE CAN ACHIEVE. DROP OR", $01 + .byte "EVEN MODIFY PACKETS IN", $01 + .byte "TRANSIT? HIDE MALICIOUS", $01 + .byte "ACTIVITY?" +ReidEnd: + +NahamsecStart: + .byte $3F, $00 + .byte $0F, $1C, $27, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $A4, $A5, $A6, $A7, $A8, $A9, $08, $01 + .byte $07, $AA, $AB, $AC, $AD, $AE, $AF, $08, $01 + .byte $07, $B0, $B1, $B2, $B3, $B4, $B5, $08, $01 + .byte $07, $B6, $B7, $B8, $B9, $BA, $BB, $08, $01 + .byte $07, $BC, $BD, $BE, $BF, $C0, $C1, $08, $01 + .byte $07, $C2, $C3, $C4, $C5, $C6, $C7, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "14:30-15:00", $02 + .byte $21, $62 + .byte "NAHAMSEC", $01, $01 + .byte "OWNING THE CLOUT THROUGH", $01 + .byte "SSRF AND PDF GENERATORS", $01, $01 + .byte "COME AND DISCUSS A NUMBER OF", $01 + .byte "DIFFERENT METHODS TO", $01 + .byte "EXFILTRATE DATA SSRF. WE", $01 + .byte "WERE ABLE TO HACK SOME OF", $01 + .byte "THE MAJOR TRANSPORTATION,", $01 + .byte "HOSPITALITY, AND SOCIAL", $01 + .byte "MEDIA COMPANIES FOR BIG", $01 + .byte "BOUNTIES!" +NahamsecEnd: + +IlyaStart: + .byte $23, $C8 + .byte %01000100, %01010101, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000 + .byte %00000100, %00000101, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, $02 + .byte $3F, $00 + .byte $0F, $24, $13, $30 + .byte $0F, $24, $13, $23, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $C8, $C9, $CA, $CB, $CC, $CD, $08, $01 + .byte $07, $CE, $CF, $D0, $D1, $D2, $D3, $08, $01 + .byte $07, $D4, $D5, $D6, $D7, $D8, $D9, $08, $01 + .byte $07, $DA, $DB, $DC, $DD, $DE, $DF, $08, $01 + .byte $07, $E0, $E1, $E2, $E3, $E4, $E5, $08, $01 + .byte $07, $E6, $E7, $E8, $E9, $EA, $EB, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "15:00-16:00", $02 + .byte $21, $62 + .byte "ILYA", $01, $01 + .byte "EMULATING IOT FIRMWARE EN", $01 + .byte "MASSE WITH DOCKER & QEMU", $01, $01 + .byte "COME SEE TECHNIQUES USING", $01 + .byte "CONTAINERS AND QEMU USED TO", $01 + .byte "EMULATE NON-X86 FIRMWARE TO", $01 + .byte "DEMONSTRATE CAPABILITIES AND", $01 + .byte "LIMITATIONS WHEN USED FOR", $01 + .byte "SECURITY RESEARCH (AND", $01 + .byte "TARGET PRACTICE)" +IlyaEnd: + +MGStart: + .byte $3F, $00 + .byte $0F, $2D, $10, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $80, $81, $82, $83, $84, $85, $08, $01 + .byte $07, $86, $87, $88, $89, $8A, $8B, $08, $01 + .byte $07, $8C, $8D, $8E, $8F, $90, $91, $08, $01 + .byte $07, $92, $93, $94, $95, $96, $97, $08, $01 + .byte $07, $98, $99, $9A, $9B, $9C, $9D, $08, $01 + .byte $07, $9E, $9F, $A0, $A1, $A2, $A3, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "16:00-16:30", $02 + .byte $21, $62 + .byte "MG", $01, $01 + .byte "RAPID PROTOTYPING CHAOS", $01, $01 + .byte "COME SEE HOW RAPID", $01 + .byte "PROTOTYPING HAS WORKED FOR", $01 + .byte "PROJECTS THAT RESULTED IN", $01 + .byte "THE DEMONSEED AND O.MG", $01 + .byte "CABLE. MG IS A THUG OF", $01 + .byte "CHAOS, AND THIS PRESENTATION", $01 + .byte "PROMISES TO BE NOTHING LESS!" +MGEnd: + +Twitch2ShellStart: + .byte $3F, $00 + .byte $0F, $2D, $27, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $A4, $A5, $A6, $A7, $A8, $A9, $08, $01 + .byte $07, $AA, $AB, $AC, $AD, $AE, $AF, $08, $01 + .byte $07, $B0, $B1, $B2, $B3, $B4, $B5, $08, $01 + .byte $07, $B6, $B7, $B8, $B9, $BA, $BB, $08, $01 + .byte $07, $BC, $BD, $BE, $BF, $C0, $C1, $08, $01 + .byte $07, $C2, $C3, $C4, $C5, $C6, $C7, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "16:30-17:00", $02 + .byte $21, $62 + .byte "TWITCH2SHELL", $01, $01 + .byte "THE TWITCH2SHELL EVENT WILL", $01 + .byte "BEGIN! YOU CAN INTERACT WITH", $01 + .byte "A REAL SHELL USING TWITCH", $01 + .byte "CHAT COMMANDS. THIS TIME CAN", $01 + .byte "BE USED FOR RIGOROUS SCRUB", $01 + .byte "DOWNS AND MAINTIANING", $01 + .byte "HEALTHY FLUID LEVELS.", $01 +Twitch2ShellEnd: + +NetspookyStart: + .byte $3F, $00 + .byte $0F, $3D, $28, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $C8, $C9, $CA, $CB, $CC, $CD, $08, $01 + .byte $07, $CE, $CF, $D0, $D1, $D2, $D3, $08, $01 + .byte $07, $D4, $D5, $D6, $D7, $D8, $D9, $08, $01 + .byte $07, $DA, $DB, $DC, $DD, $DE, $DF, $08, $01 + .byte $07, $E0, $E1, $E2, $E3, $E4, $E5, $08, $01 + .byte $07, $E6, $E7, $E8, $E9, $EA, $EB, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "17:00-17:30", $02 + .byte $21, $62 + .byte "NETSPOOKY", $01, $01 + .byte "ADVENTURES IN BINARY GOLF", $01, $01 + .byte "HIT THE BACK 9 ON AN", $01 + .byte "ADVENTURE OF BINARY MANGLING", $01 + .byte "AND MANIPULATION. LOWER YOUR", $01 + .byte "PAR WITH APPROACH, RATIONALE", $01 + .byte "AND TECHNIQUES FOR ELF AND", $01 + .byte "PE FORMATS. ENJOY TIPS,", $01 + .byte "TRICKS AND POLYGLOT TREATS", $01 + .byte "TO MINIFY YOUR GAME." +NetspookyEnd: + +CaseyStart: + .byte $3F, $00 + .byte $0F, $11, $16, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $80, $81, $82, $83, $84, $85, $08, $01 + .byte $07, $86, $87, $88, $89, $8A, $8B, $08, $01 + .byte $07, $8C, $8D, $8E, $8F, $90, $91, $08, $01 + .byte $07, $92, $93, $94, $95, $96, $97, $08, $01 + .byte $07, $98, $99, $9A, $9B, $9C, $9D, $08, $01 + .byte $07, $9E, $9F, $A0, $A1, $A2, $A3, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "17:30-18:00", $02 + .byte $21, $62 + .byte "CASEY ELLIS", $01, $01 + .byte "VIRAL VULNERABILITY", $01 + .byte "DISCLOSURE", $01, $01 + .byte "WHAT ABOUT DISCLOSURE? DOES", $01 + .byte "HACKING IN A SKIMASK MAKE", $01 + .byte "YOU A BURGLAR? MEET THE", $01 + .byte "GHOSTS OF PAST PRESENT AND", $01 + .byte "FUTURE TO CREATE", $01 + .byte "CONVERSATION BETWEEN", $01 + .byte "BUILDERS AND BREAKERS WITH", $01 + .byte "DISCLOSE.IO" +CaseyEnd: + +SilvioStart: + .byte $3F, $00 + .byte $0F, $08, $27, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $A4, $A5, $A6, $A7, $A8, $A9, $08, $01 + .byte $07, $AA, $AB, $AC, $AD, $AE, $AF, $08, $01 + .byte $07, $B0, $B1, $B2, $B3, $B4, $B5, $08, $01 + .byte $07, $B6, $B7, $B8, $B9, $BA, $BB, $08, $01 + .byte $07, $BC, $BD, $BE, $BF, $C0, $C1, $08, $01 + .byte $07, $C2, $C3, $C4, $C5, $C6, $C7, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "18:00-18:30", $02 + .byte $21, $62 + .byte "DR SILVIO CASARE", $01, $01 + .byte "MODERN LINUX HEAP", $01 + .byte "EXPLOITATION", $01, $01 + .byte "A CLASSIC HEAP OVERFLOW", $01 + .byte "CAN'T LEAD TO CODE", $01 + .byte "EXECUTION! COME SEE HOW WITH", $01 + .byte "SOME GROOMING AND A LITTLE", $01 + .byte "APPLICATION LOGIN HOW YOU", $01 + .byte "CAN DEFEAT ALL CURRENT", $01 + .byte "MITIGATIONS IN LINUX", $01 + .byte "ALLOCATORS SUCH AS PTMALLOC2" +SilvioEnd: + +SyedStart: + .byte $3F, $00 + .byte $0F, $1C, $3B, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $C8, $C9, $CA, $CB, $CC, $CD, $08, $01 + .byte $07, $CE, $CF, $D0, $D1, $D2, $D3, $08, $01 + .byte $07, $D4, $D5, $D6, $D7, $D8, $D9, $08, $01 + .byte $07, $DA, $DB, $DC, $DD, $DE, $DF, $08, $01 + .byte $07, $E0, $E1, $E2, $E3, $E4, $E5, $08, $01 + .byte $07, $E6, $E7, $E8, $E9, $EA, $EB, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "18:30-19:30", $02 + .byte $21, $62 + .byte "SYED FARAZ ABRAR", $01, $01 + .byte "HAHA V8 ENGINE GO BRRRRR", $01, $01 + .byte "V8 IS SO COMPLEX THAT IT HAS", $01 + .byte "ITS OWN BUG CLASSES", $01 + .byte "YOU'LL BE ABLE TO LEARN", $01 + .byte "ABOUT THE GORY INTERNALS OF", $01 + .byte "ONE OF THE MOST USED JS", $01 + .byte "ENGINES IN THE WORLD AND THE", $01 + .byte "BEST APPROACH FOR FINDING JS", $01 + .byte "ENGINE VULNS" +SyedEnd: + +SnyffStart: + .byte $3F, $00 + .byte $0F, $08, $27, $30, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $80, $81, $82, $83, $84, $85, $08, $01 + .byte $07, $86, $87, $88, $89, $8A, $8B, $08, $01 + .byte $07, $8C, $8D, $8E, $8F, $90, $91, $08, $01 + .byte $07, $92, $93, $94, $95, $96, $97, $08, $01 + .byte $07, $98, $99, $9A, $9B, $9C, $9D, $08, $01 + .byte $07, $9E, $9F, $A0, $A1, $A2, $A3, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "19:30-20:00", $02 + .byte $21, $62 + .byte "SNYFF", $01, $01 + .byte "CODE THAT GETS YOU", $01 + .byte "PWN(S['D)", $01, $01 + .byte "FROM REGULAR EXPRESSION", $01 + .byte "MAGIC TO UNICODE JIU-JITSU,", $01 + .byte "WE WILL END MIXING THE TWO", $01 + .byte "TO CREATE SOME", $01 + .byte "UNICODE/REGULAR EXPRESSION", $01 + .byte "KRAV MAGA FOR MAXIMUM DAMAGE", $01 + .byte "IN GOLANG, RUBY, PYTHON, C#" +SnyffEnd: + +OutbreakStart: + .byte $23, $C8 + .byte %01000100, %01000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000 + .byte %00000100, %00000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, $02 + .byte $3F, $00 + .byte $0F, $2D, $37, $30 + .byte $0F, $2D, $08, $14, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $A4, $A5, $A6, $A7, $A8, $A9, $08, $01 + .byte $07, $AA, $AB, $AC, $AD, $AE, $AF, $08, $01 + .byte $07, $B0, $B1, $B2, $B3, $B4, $B5, $08, $01 + .byte $07, $B6, $B7, $B8, $B9, $BA, $BB, $08, $01 + .byte $07, $BC, $BD, $BE, $BF, $C0, $C1, $08, $01 + .byte $07, $C2, $C3, $C4, $C5, $C6, $C7, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "20:00-20:30", $02 + .byte $21, $62 + .byte "OUTBREAK CONTAINMENT", $01, $01 + .byte "A RECAP OF THE DAYS EVENTS", $01 + .byte "WILL BE DISCUSSED. THIS WILL", $01 + .byte "INCLUDE ANNOUNCING THE", $01 + .byte "WINNERS OF THE CTF AND", $01 + .byte "CH0PP3D EVENTS." +OutbreakEnd: + +YTCrackerStart: + .byte $23, $C8 + .byte %11000100, %10001101, %00000000, %00000100, %00000000, %00000000, %00000000, %00000000 + .byte %00000100, %00000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, $02 + .byte $3F, $00 + .byte $0F, $2B, $27, $30 + .byte $0F, $11, $27, $30 + .byte $0F, $11, $27, $2B + .byte $0F, $11, $30, $2B, $02 + .byte $20, $61 + .byte $04, $05, $05, $05, $05, $05, $05, $06, $01 + .byte $07, $C8, $C9, $CA, $CB, $CC, $CD, $08, $01 + .byte $07, $CE, $CF, $D0, $D1, $D2, $D3, $08, $01 + .byte $07, $D4, $D5, $D6, $D7, $D8, $D9, $08, $01 + .byte $07, $DA, $DB, $DC, $DD, $DE, $DF, $08, $01 + .byte $07, $E0, $E1, $E2, $E3, $E4, $E5, $08, $01 + .byte $07, $E6, $E7, $E8, $E9, $EA, $EB, $08, $01 + .byte $09, $0A, $0A, $0A, $0A, $0A, $0A, $0B, $02 + .byte $21, $29 + .byte "20:30-22:35", $02 + .byte $21, $62 + .byte "YTCRACKER", $01, $01 + .byte "PANDEMIC PARTY", $01, $01 + .byte "TIME TO LET YOUR HAIR DOWN", $01 + .byte "WITH COMMUNITY EVENTS AND", $01 + .byte "MUSIC. BOOZE AND CHATTER", $01 + .byte "OPTIONAL WHILE MAINTAINING A", $01 + .byte "SAFE DISTANCE (NOT", $01 + .byte "OPTIONAL)." +YTCrackerEnd: + +PresentationsStart: + .byte $3F, $00 + .byte $0F, $0F, $0F, $30, $02 + .byte $20, $62 + .byte "PRESENTATIONS", $01, $01 + .byte "THE MAIN FOCUS OF THE EVENT", $01 + .byte "IS THE PRESENTATIONS, THESE", $01 + .byte "WILL BE HELD OVER 8 HOURS IN", $01 + .byte "30 AND 60 MINUTE BLOCKS, ", $01 + .byte "WITH A 5 MINUTE Q&A OR BREAK", $01 + .byte "TIME IN BETWEEN.", $01, $01, $01, $01 + .byte "CAPTURE THE FLAG", $01, $01 + .byte "A CTF WILL BE TAKING PLACE", $01 + .byte "FOR THE DURATION OF THE", $01 + .byte "EVENT. IT IS OPEN TO", $01 + .byte "INDIVIDUALS AND TEAMS WITH", $01 + .byte "WINNERS AND PRIZES TO BE", $01 + .byte "ANNOUNCED AT THE END OF THE", $01 + .byte "EVENT." +PresentationsEnd: + +Ch0pp3dStart: + .byte $3F, $00 + .byte $0F, $0F, $0F, $30, $02 + .byte $20, $62 + .byte "CH0PP3D!", $01, $01 + .byte "THE CH0PP3D HACK-A-THON WILL", $01 + .byte "RUN FOR THE DURATION FOR THE", $01 + .byte "EVENT. IT IS OPEN TO", $01 + .byte "INDIVIDUALS AND TEAMS WITH", $01 + .byte "WINNERS AND PRIZES TO BE", $01 + .byte "ANNOUNCED AT THE END OF THE", $01 + .byte "EVENT.", $01, $01, $01, $01 + .byte "MAINFRAME PANEL", $01, $01 + .byte "A BIG-IRON SECURITY PANEL,", $01 + .byte "FEATURING PROMINENT", $01 + .byte "MAINFRAME SECURITY EXPERTS", $01 + .byte "FROM AROUND THE WORLD (THERE", $01 + .byte "ISN'T THAT MANY OF THEM)." +Ch0pp3dEnd: + +Twitch2ShStart: + .byte $3F, $00 + .byte $0F, $0F, $0F, $30, $02 + .byte $20, $62 + .BYTE "TWITCH2SHELL", $01, $01 + .byte "THE INFAMOUS THUGCROWD", $01 + .byte "TWITCH2SHELL EVENT WILL", $01 + .byte "RETURN AT AIRGAP2020.", $01 + .byte "PARTCIPANTS OF THE TWITCH", $01 + .byte "CHAT CAN INTERACT WITH A", $01 + .byte "SHELL. THE ONLY PROBLEM IS", $01 + .byte "EVERYONE HAS TO SHARE!", $01, $01, $01, $01 + .byte "PANDEMIC PARTY", $01, $01 + .BYTE "STAY AROUND AFTER TO CHAT", $01 + .byte "WITH SPEAKERS AND GUESTS,", $01 + .byte "DISCUSS SOLUTIONS TO CH0PP3D", $01 + .byte "AND THE CTF, AND ENJOY A", $01 + .byte "LIVE DJ SET FROM YTCRACKER!" +Twitch2ShEnd: diff --git a/src/schedule.asm b/src/schedule.asm new file mode 100644 index 0000000..c711fe6 --- /dev/null +++ b/src/schedule.asm @@ -0,0 +1,159 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +SCHEDULE_MAINFRAME = $06 +SCHEDULE_LAST = $12 + + +DrawScheduleScreen: + jsr ClearPPURAM + lda PPU_STATUS + lda #$3F + sta PPU_ADDR + lda #$10 + sta PPU_ADDR + lda #$0F + sta PPU_DATA + lda #$30 + sta PPU_DATA + sta PPU_DATA + sta PPU_DATA + lda #$00 + sta yscroll + lda schedule + tax + lda (ScheduleMMC1CHRBank), X + jsr SetMMC1CHRBank + lda #$0A + jsr SetMMC1CHRBank2 + txa + asl + tax + lda (ScheduleStartOffsets), X + sta addr + inx + lda (ScheduleStartOffsets), X + sta (addr + 1) + dex + lda (ScheduleEndOffsets), X + sta addrEnd + inx + lda (ScheduleEndOffsets), X + sta (addrEnd + 1) + jsr DecompressAddr + lda #$00 + sta scheduleChange + rts + +HandleScheduleChange: + lda scheduleChange + cmp #$01 + bne HandleScheduleChangeDone + lda PPU_STATUS + lda #$3F + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + lda #$0F + ldx #$20 +HandleScheduleChangeLoop: + sta PPU_DATA + dex + bne HandleScheduleChangeLoop + lda #$02 + sta scheduleChange +HandleScheduleChangeDone: + rts + +UpdateScheduleChange: + lda scheduleChange + cmp #$02 + bne UpdateScheduleChangeDone + sta scheduleChange + jsr Blank + jsr DrawScheduleScreen + jsr ResetScroll +UpdateScheduleChangeDone: + rts + +DrawArrowSprites: + lda #$6F + sta $204 + lda #%00000000 + sta $206 + lda #$77 + sta $208 + lda #%10000000 + sta $20A + lda #$6F + sta $20C + lda #%01000000 + sta $20E + lda #$77 + sta $210 + lda #%11000000 + sta $212 + ldx #$01 + lda schedule + beq DrawLeftArrowContinue + ldx #$00 +DrawLeftArrowContinue: + stx $205 + stx $209 + ldx #$01 + cmp #SCHEDULE_LAST + beq DrawRightArrowContinue + ldx #$00 +DrawRightArrowContinue: + stx $20D + stx $211 + lda frames + ror + ror + sta tmp + and #%00000100 + bne DrawArrowMoveIn + lda tmp + and #%00000011 + eor #%00000011 + jmp DrawArrowMoveContinue +DrawArrowMoveIn: + lda tmp + and #%00000011 +DrawArrowMoveContinue: + sta tmp + lda #$05 + sec + sbc tmp + sta $207 + sta $20B + lda #$F3 + clc + adc tmp + sta $20F + sta $213 +DrawArrowSpritesDone: + rts diff --git a/src/screen.asm b/src/screen.asm new file mode 100644 index 0000000..44322c8 --- /dev/null +++ b/src/screen.asm @@ -0,0 +1,374 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +SCREEN_TITLE = $00 +SCREEN_TWITCH_CHAT = $01 +SCREEN_SCHEDULE = $02 +SCREEN_EXTRA = $03 + + +;;;; +; +; screen +; 7 bit 0 +; ---- ---- +; ||| |||| +; ||| |+++- Current Screen +; ||| | +; ||| +---- TransitionFlag +; ||| +; +++------- Last Screen +; +;;;;; + + +InitializeScreen: + lda #$01 + sta allowUpdate + lda screen + and #%00000111 + sta tmp + lda screen + lsr + lsr + lsr + lsr + lsr + cmp tmp + bne InitializeScreenContinue + rts +InitializeScreenContinue: + lda screen + and #%00001000 + beq InitializeScreenNotTransition + jsr TransitionScreen + dec allowUpdate + rts +InitializeScreenNotTransition: + dec allowUpdate + jsr Blank + jsr ClearPPURAM + jsr ClearScreen + lda screen + and #%00000111 + cmp #SCREEN_TWITCH_CHAT + bne InitializeScreenNotTwitchChat + ; Screen IS Twitch Chat + lda #$00 + sta nametable + lda #MIRRORING_H + sta mirroring + lda #$00 + sta chrSwitchSize + jsr MMC1Initialize + jsr InitializeTwitchChatScreen + lda #SCREEN_TWITCH_CHAT + jmp InitializeScreenDone +InitializeScreenNotTwitchChat: + cmp #SCREEN_SCHEDULE + bne InitializeScreenNotSchedule + ; Screen IS Schedule + lda #$00 + sta nametable + lda #MIRRORING_H + sta mirroring + lda #$01 + sta chrSwitchSize + jsr MMC1Initialize + jsr InitializeScheduleScreen + lda #$00 + sta schedule + lda #SCREEN_SCHEDULE + jmp InitializeScreenDone +InitializeScreenNotSchedule: + cmp #SCREEN_EXTRA + bne InitializeScreenNotExtra + ; Screen IS Extra + lda #$00 + sta nametable + lda #$00 + sta chrSwitchSize + jsr MMC1Initialize + lda #SCREEN_EXTRA + jmp InitializeScreenDone +InitializeScreenNotExtra: +InitializeScreenCatchallTitle: + ; Screen is Catchall, so show Title + lda #MIRRORING_V + sta mirroring + lda #$00 + sta chrSwitchSize + jsr MMC1Initialize + jsr InitializeTitleScreen + lda #SCREEN_TITLE +InitializeScreenDone: + inc allowUpdate + and #%00000111 + sta screen + asl screen + asl screen + asl screen + asl screen + asl screen + ora screen + sta screen + jsr InitializeDrawBuffer + jsr ResetScroll + rts + + +TransitionScreen: + lda screen + and #%00000111 + cmp #SCREEN_TWITCH_CHAT + bne TransitionScreenNotTwitchChat + jsr TransitionTwitchChatScreen + rts +TransitionScreenNotTwitchChat: + cmp #SCREEN_SCHEDULE + bne TransitionScreenNotSchedule + jsr TransitionScheduleScreen + rts +TransitionScreenNotSchedule: + cmp #SCREEN_EXTRA + bne TransitionScreenNotExtra: + jsr TransitionExtraScreen + rts +TransitionScreenNotExtra: + rts + + +TransitionTwitchChatScreen: + lda $200 + cmp #$EF + bcc TransitionTwitchChatScreenNotInitialize + lda #$EE + sta $200 + rts +TransitionTwitchChatScreenNotInitialize: + sec + sbc #$08 + bcs TransitionTwitchChatDone + ; Start Screen ; Toggle transition to false + jsr SetBlackPalette + lda #$00 + sta nametable + lda screen + and #%00000111 + sta screen + jsr ClearSprites + rts +TransitionTwitchChatDone: + sta $200 + jsr TransitionTwitchChatSprite0Hit + rts + + +TransitionScheduleScreen: + lda $200 + cmp #$EF + bcc TransitionScheduleScreenNotInitialize + lda #$00 + sta $200 + rts +TransitionScheduleScreenNotInitialize: + adc #$08 + cmp #$EF + bcc TransitionScheduleDone + ; Start Screen ; Toggle transition to false + jsr SetBlackPalette + lda #$00 + sta nametable + lda screen + and #%00000111 + sta screen + jsr ClearSprites + rts +TransitionScheduleDone: + sta $200 + lda #$01 + sta nametable + jsr TransitionScheduleSprite0Hit + rts + + +TransitionExtraScreen: + lda #$01 + sta nametable + lda #%10000001 + sta PPU_CTRL + lda xscroll + sec + sbc #$04 + sta xscroll + cmp #$FF + bne TransitionExtraScreenContinue: + jsr SetBlackPalette + lda #$00 + sta xscroll + sta xscrollSlice + lda #$01 + sta nametable + lda screen + and #%00000111 + sta screen + jsr ClearSprites + rts +TransitionExtraScreenContinue: + lda #$01 + sta nametable + lda xscrollSlice + clc + adc #$04 + sta xscrollSlice + jsr TransitionExtraSprite0Hit + rts + + +TransitionTwitchChatSprite0Hit: +TransitionTwitchChatSprite0ClearWait: + bit $2002 + bvs TransitionTwitchChatSprite0ClearWait +TransitionTwitchChatSprite0HitWait: + bit $2002 + bvc TransitionTwitchChatSprite0HitWait: + lda #$00 + sta xscrollSlice + lda #$01 + sta nametableSlice + lda $200 + clc + adc #$06 + sta yscrollSlice + jsr SplitScroll + rts + + +TransitionScheduleSprite0Hit: +TransitionScheduleSprite0ClearWait: + bit $2002 + bvs TransitionScheduleSprite0ClearWait +TransitionScheduleSprite0HitWait: + bit $2002 + bvc TransitionScheduleSprite0HitWait: + lda #$00 + sta xscrollSlice + lda #$00 + sta nametableSlice + lda $200 + sec + sbc #$06 + sta yscrollSlice + jsr SplitScroll + rts + + +TransitionExtraSprite0Hit: +TransitionExtraSprite0ClearWait: + bit $2002 + bvs TransitionExtraSprite0ClearWait +TransitionExtraSprite0HitWait: + bit $2002 + bvc TransitionExtraSprite0HitWait: + lda #$00 + sta nametable + lda xscroll + sta tmp + lda xscrollSlice + sta xscroll + + lda #%10001000 + sta PPU_CTRL + lda xscroll + sta PPU_SCROLL + lda yscroll + sta PPU_SCROLL + + lda tmp + sta xscroll + rts + + +InitializeTitleScreen: + lda #$00 + jsr SetMMC1CHRBank + lda #%01000000 + sta emphasis + lda #%00001000 + sta patterns + jsr SetTitlePalette + jsr ClearAttributes + jsr SetTitleScreenAttributes + lda #$00 + sta xscroll + jsr DrawTitleScreen + rts + + +InitializeTwitchChatScreen: + lda #$02 + jsr SetMMC1CHRBank + lda #%00000000 + sta emphasis + lda #%00011000 + sta patterns + jsr SetChatAddrStart + jsr SetTwitchChatPalette + jsr InitializeDrawBuffer + rts + + +SetChatAddrStart: + lda fps + cmp #60 + beq SetChatAddrStartNotPAL + lda #PAL_START_ADDR_0 + sta chatAddr + lda #PAL_START_ADDR_1 + sta (chatAddr + 1) + lda #PAL_START_BANK + sta chatBank + jmp SetChatAddrStartDone +SetChatAddrStartNotPAL: + lda #NTSC_START_ADDR_0 + sta chatAddr + lda #NTSC_START_ADDR_1 + sta (chatAddr + 1) + lda #NTSC_START_BANK + sta chatBank +SetChatAddrStartDone: + jsr SetMMC1PRGBank + lda #$20 + sta ppuAddr + lda #$61 + sta (ppuAddr + 1) + rts + + +InitializeScheduleScreen: + lda #%00000000 + sta emphasis + jsr DrawScheduleScreen + rts diff --git a/src/scroll.asm b/src/scroll.asm new file mode 100644 index 0000000..19465ec --- /dev/null +++ b/src/scroll.asm @@ -0,0 +1,47 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + +SplitScroll: + lda PPU_STATUS + lda nametableSlice + asl + asl + sta PPU_ADDR + lda yscrollSlice + sta PPU_SCROLL + lda xscrollSlice + sta PPU_SCROLL + lda xscrollSlice + lsr + lsr + lsr + sta tmp + lda yscrollSlice + and #%00111000 + asl + asl + ora tmp + sta PPU_ADDR + rts diff --git a/src/title.asm b/src/title.asm new file mode 100644 index 0000000..355e44d --- /dev/null +++ b/src/title.asm @@ -0,0 +1,205 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +SetTitlePalette: + lda PPU_STATUS + lda #$3F + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + lda #$27 + sta PPU_DATA + sta PPU_DATA + lda #$17 + sta PPU_DATA + lda #$0F + sta PPU_DATA + lda #$27 + sta PPU_DATA + lda #$0F + sta PPU_DATA + lda #$17 + sta PPU_DATA + lda #$0F + sta PPU_DATA + lda #$27 + sta PPU_DATA + lda #$0F + sta PPU_DATA + lda #$17 + sta PPU_DATA + lda #$0F + sta PPU_DATA + lda #$27 + sta PPU_DATA + lda #$0F + sta PPU_DATA + lda #$17 + sta PPU_DATA + lda #$0F + sta PPU_DATA +SetSpritePalettes: + lda #$27 + sta PPU_DATA + sta PPU_DATA + lda #$0F + sta PPU_DATA + sta PPU_DATA + lda #$27 + sta PPU_DATA + lda #$0F + sta PPU_DATA + sta PPU_DATA + sta PPU_DATA + lda #$27 + sta PPU_DATA + lda #$0F + sta PPU_DATA + sta PPU_DATA + sta PPU_DATA + lda #$27 + sta PPU_DATA + lda #$0F + sta PPU_DATA + sta PPU_DATA + sta PPU_DATA + rts + + +DrawTitleScreen: + jsr ClearScreen + + lda #<(TitleBackgroundMap) + sta addr + lda #>(TitleBackgroundMap) + sta (addr + 1) + lda #<(TitleBackgroundMapEnd) + sta addrEnd + lda #>(TitleBackgroundMapEnd) + sta (addrEnd + 1) + jsr DecompressAddr + + jsr ClearTitleNametable1Solid01 + jsr DrawCursor + lda #$00 + sta yscroll + rts + + +ClearTitleNametable1Solid01: + lda PPU_STATUS + lda #$24 + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + lda #$B0 + ldx #240 + ldy #$04 +ClearTitleNametable1Solid01Loop: + sta PPU_DATA + dex + bne ClearTitleNametable1Solid01Loop + ldx #240 + dey + bne ClearTitleNametable1Solid01Loop + rts + + +DrawCursor: + lda #$B7 + sta $204 + lda #$01 + sta $205 + lda #$01 + sta $206 + lda #$78 + sta $207 + rts + + +ClearSprites: + ldx #00 +ClearSpritesLoop: + lda #$FE + sta $0200, x + inx + bne ClearSpritesLoop + rts + + +SetSwipePixelMiddle: + lda #$7F + sta $200 + lda #$00 + sta $201 + lda #$01 + sta $202 + lda #$00 + sta $203 + rts + + +SetSwipePixelTop: + lda #$FF + sta $200 + lda #$00 + sta $201 + lda #$01 + sta $202 + lda #$00 + sta $203 + rts + + +SetSwipePixelBottom: + lda #$EF + sta $200 + lda #$00 + sta $201 + lda #$00 + sta $202 + lda #$00 + sta $203 + rts + + +SetTitleScreenAttributes: + sta PPU_STATUS + lda #$27 + sta PPU_ADDR + lda #$C0 + sta PPU_ADDR + ldy #15 + ldx #$08 + lda #$55 +SetTitleScreenAttributesByteLoop: + sta PPU_DATA + dex + bne SetTitleScreenAttributesByteLoop + ldx #$08 + dey + bne SetTitleScreenAttributesByteLoop + rts diff --git a/src/twitchchat/ntsc.txt b/src/twitchchat/ntsc.txt new file mode 100644 index 0000000..43c01e9 Binary files /dev/null and b/src/twitchchat/ntsc.txt differ diff --git a/src/twitchchat/pal.txt b/src/twitchchat/pal.txt new file mode 100644 index 0000000..59ecc5f Binary files /dev/null and b/src/twitchchat/pal.txt differ diff --git a/src/zero.asm b/src/zero.asm new file mode 100644 index 0000000..d3fd34e --- /dev/null +++ b/src/zero.asm @@ -0,0 +1,91 @@ +; Copyright (C) 2020, Vi Grey +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; 1. Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +; SUCH DAMAGE. + + +GetZeroCount: + lda #$00 + tay + sta zeroFrames + lda chatByte + cmp #$01 + bne GetZeroCountChatByteNot1 + lda #$00 + sta chatByte + sta (zeroFrames + 1) + lda #31 + sta (zeroFrames + 2) + jsr IncChatAddr + rts +GetZeroCountChatByteNot1: + cmp #$02 + bne GetZeroCountChatByteNot2 + ; chatByte is 2 + lda #$00 + sta chatByte + jsr IncChatAddr + lda (chatAddr), Y + sta (zeroFrames + 1) + jsr IncChatAddr + lda (chatAddr), Y + sta (zeroFrames + 2) + jsr IncChatAddr + rts +GetZeroCountChatByteNot2: + ; chatByte is 3 + lda #$00 + sta chatByte + jsr IncChatAddr + lda (chatAddr), Y + sta zeroFrames + jsr IncChatAddr + lda (chatAddr), Y + sta (zeroFrames + 1) + jsr IncChatAddr + lda (chatAddr), Y + sta (zeroFrames + 2) + jsr IncChatAddr + rts + + +DecZeroCount: + lda (zeroFrames + 2) + sec + sbc #$01 + sta (zeroFrames + 2) + lda (zeroFrames + 1) + sbc #$00 + sta (zeroFrames + 1) + lda zeroFrames + sbc #$00 + sta zeroFrames + rts + + +CheckZeroCount: + lda #$00 + ora zeroFrames + ora (zeroFrames + 1) + ora (zeroFrames + 2) + rts