Commit: 95625944513ea0f3fc1dd0e7262a932a75e01417 Author: Vi Grey Date: 2020-12-08 11:10 UTC Summary: Initial Commit - Add Ian Coldwater Portrait IanColdwater/LICENSE | 24 ++++++++++++ IanColdwater/Makefile | 51 ++++++++++++++++++++++++ IanColdwater/README.md | 78 ++++++++++++++++++++++++++++++++++++ IanColdwater/SHA256SUMS.txt | 12 ++++++ IanColdwater/bin/IanColdwater.nes | Bin 0 -> 40976 bytes IanColdwater/src/IanColdwater.asm | 46 ++++++++++++++++++++++ IanColdwater/src/controller.asm | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ IanColdwater/src/defs.asm | 50 +++++++++++++++++++++++ IanColdwater/src/draw.asm | 52 ++++++++++++++++++++++++ IanColdwater/src/graphics/portrait.nam | Bin 0 -> 1024 bytes IanColdwater/src/graphics/tileset.chr | Bin 0 -> 8192 bytes IanColdwater/src/portrait.asm | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ IanColdwater/src/prg.asm | 87 ++++++++++++++++++++++++++++++++++++++++ IanColdwater/src/ram.asm | 33 ++++++++++++++++ 14 files changed, 732 insertions(+) diff --git a/IanColdwater/LICENSE b/IanColdwater/LICENSE new file mode 100755 index 0000000..52e0bca --- /dev/null +++ b/IanColdwater/LICENSE @@ -0,0 +1,24 @@ +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/IanColdwater/Makefile b/IanColdwater/Makefile new file mode 100644 index 0000000..3cae768 --- /dev/null +++ b/IanColdwater/Makefile @@ -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. + +PKG_NAME := IanColdwater +CURRENTDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +all: + mkdir -p $(CURRENTDIR)bin/build; \ + mkdir -p $(CURRENTDIR)build/$(PKG_NAME)/src; \ + cd $(CURRENTDIR)src; \ + asm $(PKG_NAME).asm ../build/partial.nes; \ + cd $(CURRENTDIR); \ + cp -r src build/$(PKG_NAME); \ + cp LICENSE build/$(PKG_NAME); \ + cp Makefile build/$(PKG_NAME); \ + cp README.md build/$(PKG_NAME); \ + cp SHA256SUMS.txt build/$(PKG_NAME); \ + cd $(CURRENTDIR)build; \ + zip -r $(PKG_NAME).zip $(PKG_NAME); \ + ZIPSIZE=$$(stat -L -c %s $(PKG_NAME).zip); \ + head -c $$((32778 - $$ZIPSIZE)) partial.nes > partial.zip; \ + cat $(PKG_NAME).zip >> partial.zip; \ + zip -F partial.zip --out partial-new.zip; \ + tail -c 8198 partial.nes >> partial-new.zip; \ + cp partial-new.zip $(CURRENTDIR)/bin/build/$(PKG_NAME).nes; \ + +clean: + rm -rf -- $(CURRENTDIR)build; \ + rm -rf -- $(CURRENTDIR)bin/build; \ diff --git a/IanColdwater/README.md b/IanColdwater/README.md new file mode 100755 index 0000000..ca3f22e --- /dev/null +++ b/IanColdwater/README.md @@ -0,0 +1,78 @@ +# Hacker Portrait for NES - Ian Coldwater + +An NES ROM portrait of Ian Coldwater + +**_"NES Hacker Portrait - Ian Coldwater" was created by Vi Grey and is licensed under the BSD 2-Clause License._** + +### Description: +An NES ROM in the Hacker Portrait for NES series. This portrait is of Ian Coldwater. + +------ +## **RUNNING THE NES ROM ON AN EMULATOR** + +This NES ROM will run on essentially any NES emulator that can run Super Mario Bros., as this ROM uses the same ROM Mapper type as Super Mario Bros. + + +------ +## **BUILDING THE NES ROM SOURCE CODE** + +### Build Platforms: +- \*BSD +- Linux +- macOS + +### NES ROM 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) +- **zip** + +### 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/build/IanColdwater.nes** + +### Clean Build Environment: +If you used `make` to build the NES ROM, you can run the following command to clean up the build environment. +```sh +make clean +``` +------ +## **EXTRAS** +#### Unzipping the ROM: +The NES ROM file at **bin/IanColdwater.nes** (or you built the NES ROM yourself, **bin/build/IanColdwater.nes**) will also be a functioning ZIP file that contains its own source code when unzipped. + +#### Modify Hair/Shirt/Lip color +Press **LEFT** or **RIGHT** on Controller 1 or Controller 2 to cycle through hair colors. Press **DOWN** or **UP** on Controller 1 or 2 to cycle through shirt colors. Press **B** or **A** on Controller 1 or 2 to cycle through lip colors. Press **START** or **SELECT** to set hair/shirt/lip colors back to the default palette values. + +------ +## **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/IanColdwater/SHA256SUMS.txt b/IanColdwater/SHA256SUMS.txt new file mode 100644 index 0000000..f8d5dcc --- /dev/null +++ b/IanColdwater/SHA256SUMS.txt @@ -0,0 +1,12 @@ +a12f11fba0203891dfc0ae21842c857a678bebad03347e003b858601305808e7 LICENSE +85f3eaca22d0f3c85573554bd0aae6b93b0e003efa6ea14db1f32a3c0484f75e Makefile +11cf261c54e8d9ab063465553bf8467bb9b9af725b0a1074182761b004944ac1 README.md +da0679571e26b2c2a3f00a478dda3c1bea963aabbb37fee05cccc0430532c30e src/controller.asm +ad89850fc9014442e9237544084c0c4da9010b6d56043e4111fce1f57d989da4 src/defs.asm +d77da8f648b00bbf5a9d5a550f15ffd8e117da44ae9f74ba7057d74602ce709a src/draw.asm +5e052f9c9dc6f91f3155386a1c03b46d331950272a86dc3b8c9ba8f6b08c5445 src/IanColdwater.asm +1a24746d187f7738ea30c1af62bd6c324ee9af36c530fc3b1cd75ad321508465 src/portrait.asm +5345a6e6d4481e8842cb8208f885943bfc548eac6d90ba1d5293419112c6f71c src/prg.asm +1fe5e6f71b324b65dd54c03975021a15b8bfca5d2715bd07a216f5cf02d641fa src/ram.asm +a5f727ccc67ed37903ddf2bc73f89760952491e8d334bb7a127a942c2d02beea src/graphics/portrait.nam +6c03f5bd34e1deb34a046bda9f8f76b46ffb074f952f54ff2a1b28a3faa2f6cd src/graphics/tileset.chr diff --git a/IanColdwater/bin/IanColdwater.nes b/IanColdwater/bin/IanColdwater.nes new file mode 100644 index 0000000..ca5f942 Binary files /dev/null and b/IanColdwater/bin/IanColdwater.nes differ diff --git a/IanColdwater/src/IanColdwater.asm b/IanColdwater/src/IanColdwater.asm new file mode 100644 index 0000000..46e1863 --- /dev/null +++ b/IanColdwater/src/IanColdwater.asm @@ -0,0 +1,46 @@ +; 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. + + .db "NES", $1A + .db $02 + .db $01 + .db $00 + .db $00 + .db 0, 0, 0, 0, 0, 0, 0, 0 + +.include "ram.asm" +.include "defs.asm" + +.base $8000 + +.include "prg.asm" + + .pad CALLBACK, #$FF + .dw NMI + .dw RESET + .dw 0 + +.base $0000 + .incbin "graphics/tileset.chr" diff --git a/IanColdwater/src/controller.asm b/IanColdwater/src/controller.asm new file mode 100644 index 0000000..9f464be --- /dev/null +++ b/IanColdwater/src/controller.asm @@ -0,0 +1,170 @@ +; 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. + +PollController: + lda #$01 + sta CONTROLLER_1 + lda #$00 + sta CONTROLLER_1 + ldx #$08 +PollControllerLoop: + lda CONTROLLER_1 + lsr + rol controller1 + lda CONTROLLER_2 + lsr + rol controller2 + dex + bne PollControllerLoop + lda controller1 + ora controller2 + sta controller1 + rts + +UpdateController: + lda controller1 + sta controllerLastFrame + jsr PollController + jsr CheckRight + jsr CheckLeft + jsr CheckUp + jsr CheckDown + jsr CheckA + jsr CheckB + jsr CheckStart + jsr CheckSelect + rts + +CheckRight: + lda controller1 + and #BUTTON_RIGHT + beq CheckRightDone + lda controller1 + and #BUTTON_LEFT + bne CheckRightDone + lda controllerLastFrame + and #BUTTON_RIGHT + bne CheckRightDone + ldx #$03 + jsr IncPaletteVal +CheckRightDone: + rts + +CheckLeft: + lda controller1 + and #BUTTON_LEFT + beq CheckLeftDone + lda controller1 + and #BUTTON_RIGHT + bne CheckLeftDone + lda controllerLastFrame + and #BUTTON_LEFT + bne CheckLeftDone + ldx #$03 + jsr DecPaletteVal +CheckLeftDone: + rts + +CheckUp: + lda controller1 + and #BUTTON_UP + beq CheckUpDone + lda controller1 + and #BUTTON_DOWN + bne CheckUpDone + lda controllerLastFrame + and #BUTTON_UP + bne CheckUpDone + ldx #$01 + jsr IncPaletteVal +CheckUpDone: + rts + +CheckDown: + lda controller1 + and #BUTTON_DOWN + beq CheckDownDone + lda controller1 + and #BUTTON_UP + bne CheckDownDone + lda controllerLastFrame + and #BUTTON_DOWN + bne CheckDownDone + ldx #$01 + jsr DecPaletteVal +CheckDownDone: + rts + +CheckA: + lda controller1 + and #BUTTON_A + beq CheckADone + lda controller1 + and #BUTTON_B + bne CheckADone + lda controllerLastFrame + and #BUTTON_A + bne CheckADone + ldx #$00 + jsr IncPaletteVal +CheckADone: + rts + +CheckB: + lda controller1 + and #BUTTON_B + beq CheckBDone + lda controller1 + and #BUTTON_A + bne CheckBDone + lda controllerLastFrame + and #BUTTON_B + bne CheckBDone + ldx #$00 + jsr DecPaletteVal +CheckBDone: + rts + +CheckStart: + lda controller1 + and #BUTTON_START + beq CheckStartDone + lda controllerLastFrame + and #BUTTON_START + bne CheckStartDone + jsr InitializePortraitVars +CheckStartDone: + rts + +CheckSelect: + lda controller1 + and #BUTTON_SELECT + beq CheckSelectDone + lda controllerLastFrame + and #BUTTON_SELECT + bne CheckSelectDone + jsr InitializePortraitVars +CheckSelectDone: + rts diff --git a/IanColdwater/src/defs.asm b/IanColdwater/src/defs.asm new file mode 100644 index 0000000..2947f62 --- /dev/null +++ b/IanColdwater/src/defs.asm @@ -0,0 +1,50 @@ +; 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. + +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 + +OAM_DMA = $4014 +APU_FRAME_COUNTER = $4017 + +CALLBACK = $FFFA + +CONTROLLER_1 = $4016 +CONTROLLER_2 = $4017 + +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 diff --git a/IanColdwater/src/draw.asm b/IanColdwater/src/draw.asm new file mode 100644 index 0000000..2e2c3f6 --- /dev/null +++ b/IanColdwater/src/draw.asm @@ -0,0 +1,52 @@ +; 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: + lda #$00 + sta PPU_SCROLL + sta PPU_SCROLL + jsr EnableNMI + rts + +Draw: + lda #%00001010 + sta PPU_MASK + rts + +DisableNMI: + lda #%00000000 + sta PPU_CTRL + rts + +EnableNMI: + lda #%10000000 + sta PPU_CTRL + rts + +Blank: + lda #%00000110 + sta PPU_MASK + jsr DisableNMI + rts diff --git a/IanColdwater/src/graphics/portrait.nam b/IanColdwater/src/graphics/portrait.nam new file mode 100644 index 0000000..ff0ab66 Binary files /dev/null and b/IanColdwater/src/graphics/portrait.nam differ diff --git a/IanColdwater/src/graphics/tileset.chr b/IanColdwater/src/graphics/tileset.chr new file mode 100644 index 0000000..dd5b5ee Binary files /dev/null and b/IanColdwater/src/graphics/tileset.chr differ diff --git a/IanColdwater/src/portrait.asm b/IanColdwater/src/portrait.asm new file mode 100644 index 0000000..be9bff9 --- /dev/null +++ b/IanColdwater/src/portrait.asm @@ -0,0 +1,129 @@ +; 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. + +DrawPortrait: + jsr InitializePortraitVars + jsr DrawPortraitNametable + lda #$01 + sta needDraw + jsr SetPalette + rts + +DrawPortraitNametable: + lda #<(PortraitNametable) + sta addr + lda #>(PortraitNametable) + sta (addr + 1) + ldy #$00 + ldx #$04 + lda PPU_STATUS + lda #$20 + sta PPU_ADDR + sty PPU_ADDR +DrawPortraitNametableLoop: + lda (addr), Y + sta PPU_DATA + iny + bne DrawPortraitNametableLoop + inc (addr + 1) + dex + bne DrawPortraitNametableLoop + rts + +InitializePortraitVars: + lda #$0F + sta (palettes + 3) + lda #$05 + sta (palettes + 2) + lda #$0E + sta (palettes + 1) + lda #$10 + sta palettes + lda #$01 + sta needDraw + rts + +SetPalette: + lda PPU_STATUS + lda #$3F + sta PPU_ADDR + lda #$00 + sta PPU_ADDR + ldx #$03 +SetPaletteLoop: + lda #$2d + sta PPU_DATA + lda #$36 + sta PPU_DATA + lda palettes, X + tay + lda PaletteList, Y + sta PPU_DATA + lda #$0F + sta PPU_DATA + dex + bpl SetPaletteLoop + jsr ResetScroll + rts + +IncPaletteVal: + inc palettes, X + lda palettes, X + cmp #$36 + bcc IncPaletteValDone + lda #$00 + sta palettes, X +IncPaletteValDone: + lda #$01 + sta needDraw + rts + +DecPaletteVal: + dec palettes, X + bpl DecPaletteValDone + lda #$35 + sta palettes, X +DecPaletteValDone: + lda #$01 + sta needDraw + rts + +PaletteList: + .byte $0F, $2D, $00, $10, $3D, $30 + .byte $01, $11, $21, $31 + .byte $02, $12, $22, $32 + .byte $03, $13, $23, $33 + .byte $04, $14, $24, $34 + .byte $05, $15, $25, $35 + .byte $06, $16, $26, $36 + .byte $07, $17, $27, $37 + .byte $08, $18, $28, $38 + .byte $09, $19, $29, $39 + .byte $0A, $1A, $2A, $3A + .byte $0B, $1B, $2B, $3B + .byte $0C, $1C, $2C, $3C + +PortraitNametable: + .incbin "graphics/portrait.nam" diff --git a/IanColdwater/src/prg.asm b/IanColdwater/src/prg.asm new file mode 100644 index 0000000..825c5ce --- /dev/null +++ b/IanColdwater/src/prg.asm @@ -0,0 +1,87 @@ +; 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 + lda #%00000000 + sta PPU_CTRL + stx $4010 + ldy #$00 + +VBlankWait: + ldx #$02 +VBlankWaitLoop: + lda PPU_STATUS + bpl VBlankWaitLoop + dex + bne VBlankWaitLoop + + + jsr DrawPortrait + +Forever: + jmp Forever + +NMI: + pha + txa + pha + tya + pha + lda #$00 + sta PPU_OAM_ADDR + lda #$02 + sta OAM_DMA + lda needDraw + beq NMISkipDraw + lda PPU_STATUS + jsr Draw + jsr ResetScroll + jsr SetPalette + dec needDraw +NMISkipDraw: + jsr Update + pla + tay + pla + tax + pla + rti + +Update: + jsr UpdateController + rts + +.include "draw.asm" +.include "portrait.asm" +.include "controller.asm" diff --git a/IanColdwater/src/ram.asm b/IanColdwater/src/ram.asm new file mode 100644 index 0000000..f32dc77 --- /dev/null +++ b/IanColdwater/src/ram.asm @@ -0,0 +1,33 @@ +; 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 + addr dsb 2 + palettes dsb 4 + controller1 dsb 1 + controller2 dsb 1 + controllerLastFrame dsb 1 + needDraw dsb 1 +.ende