├── zef.cst ├── bak ├── zef.cst ├── .gitattributes ├── .gitignore ├── interrupt.asm ├── README.md ├── zef.bas ├── xxx.asm ├── window.asm ├── shifting.asm ├── zefscreen.sdd ├── zef2.asm ├── zef1.asm └── zef3.asm ├── zefeldar_test ├── test.txt ├── New Disk (D64).d64 ├── map2.txt ├── map3.txt ├── map1.txt ├── map2 - Copy.txt └── map3 - Copy.txt ├── .gitattributes ├── .gitignore ├── interrupt.asm ├── disk.asm ├── README.md ├── disk2.asm ├── SOUND_Move.asm ├── zef.bas ├── charset.asm ├── xxx.asm ├── window.asm ├── SOUND_Blocked.asm ├── window2.asm ├── shifting.asm ├── drawmap.asm ├── zefscreen.sdd ├── charset2.asm ├── zef2.asm ├── box.asm ├── zef1.asm ├── zef3.asm └── zef4.asm /zef.cst: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bak/zef.cst: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /zefeldar_test/test.txt: -------------------------------------------------------------------------------- 1 | aaaaaaaaaaa 2 | bbbbbbbbbbb 3 | ddddddddddd 4 | eeeeeeeeeee 5 | fffffffffff -------------------------------------------------------------------------------- /zefeldar_test/New Disk (D64).d64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graydefender/Zef-Series/HEAD/zefeldar_test/New Disk (D64).d64 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /bak/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /zefeldar_test/map2.txt: -------------------------------------------------------------------------------- 1 | --------------+---------------------------------..............+................+..............................+................+................---------------................-----------------.....................................................----------------------------------..............+..........+.town center.+.......+..............+..........+-------------+.......+..............+................................+..............+................................+..............------------.............--------+.........................................................-------------------...........------------------..................+...........+...................................+...........+...................................+...........+................. -------------------------------------------------------------------------------- /zefeldar_test/map3.txt: -------------------------------------------------------------------------------- 1 | @@::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::::::::@@@@@@@@@@@@@@@@@:::::::::::@@@@@@@@@@@@:::::::@@@@@@@@@@@@@@::::::::::::::@@@@@@@@@@@@@@@::::@@@@@@@@@@@@:::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::::::@@@@@@@:::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@:::::::::::::::@@@@@@@@@@@@@@@@@@@@@:::::::::::::::::::::::::::@@@@@@@@@@@@@@@@@@@@@@@:::::::::::++oo+:::::::::::::@@@@@@@@@@@@@@@@@@@@@@:::::::+++oo+::::::::@@@@@@@@@@@@@@@@@@@@@@::::::::::::+++++:::::::::::::@@@@@@@@@@@@@@@@@@@@:::::::::::::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::::::@@@@@@@:::::::::::@@@@@@@@@@@@@@@@@@@@@@@:::::::::@@@@@@@@:::::::@@@@@@@@@@@@@@@@@@@@@@@@@::::::::@@@@ 2 | -------------------------------------------------------------------------------- /zefeldar_test/map1.txt: -------------------------------------------------------------------------------- 1 | @@@@@@@@@@@@@@@@@@@@::::::@@@@@@@@@@@@@@@@@@@@@@ 2 | @@@@@@@@@@@@@@@@@@@@@:::::@@@@@@::---::::@@@@::@ 3 | @@@@@::::::::*@@@@@@@@@::@@@@@@::--@@@@::@@@@::@ 4 | @@@@@:::::::::@@@@@@@@@@@@@@@@::---@@@@::::@@@@@ 5 | @@@@@@@:+++::::::@@@@@@@@@@::::---:@@@@@:::@@@@@ 6 | @@@@@@@@@@:::::::::@@@@@@@:::::---:@@@@@@@:@@@@@ 7 | @@@@@@@@@@@@@@@@:::::::::::@@@@@@@@@@@@@@@:@@::@ 8 | @@::::::@@@@@@@@::::::::@@@@@@@@@@@@@@@@@@:@@@@@ 9 | @@:::::::@@@@@@@::@#@@@@@@@@@@@@@@@@@@@@@::@@@@@ 10 | @@@@@@@@@@@@@@@@::@@@@@@@@@@:::::@@@@@::::::@@@@ 11 | @@@@@@@@@@@@@@@@::@@@@@@@@::::oo::::::::@@@@@@@@ 12 | @@@@@@@@::::::::::::@@@@@@@@:::::@@@@@@@@@@@@@@@ 13 | @@@@@@@@@@@::::ooo::::::::::oo:@@@@@@@@@@@@@@@@@ 14 | @@@@@@@@@@@@@@@@@::::ooo:::::::@@@@@@@@@@@@@@@@@ 15 | @@@@@@@@@@@@@@::::::ooo:::@@@@@@@@@@@@@:::ooo:@@ 16 | @@@@@@@@@@@@@@@@@@:::::::::@@@@@@@@@@@@@::oo:::@ -------------------------------------------------------------------------------- /zefeldar_test/map2 - Copy.txt: -------------------------------------------------------------------------------- 1 | --------------+--------------------------------- 2 | ..............+................+................ 3 | ..............+................+................ 4 | ---------------................----------------- 5 | ................................................ 6 | .....----------------------------------......... 7 | .....+..........+.TOWN CENTER.+.......+......... 8 | .....+..........+-------------+.......+......... 9 | .....+................................+......... 10 | .....+................................+......... 11 | .....------------.............--------+......... 12 | ................................................ 13 | -------------------...........------------------ 14 | ..................+...........+................. 15 | ..................+...........+................. 16 | ..................+...........+................. -------------------------------------------------------------------------------- /zefeldar_test/map3 - Copy.txt: -------------------------------------------------------------------------------- 1 | @@::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::::::::@@@ 2 | @@@@@@@@@@@@@@:::::::::::@@@@@@@@@@@@:::::::@@@@ 3 | @@@@@@@@@@::::::::::::::@@@@@@@@@@@@@@@::::@@@@@ 4 | @@@@@@@:::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5 | @@@@@@@@@@@@@::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 6 | @@@@@@@@@@@@@::::::@@@@@@@:::::::::::::@@@@@@@@@ 7 | @@@@@@@@@@@@@@@@:::::::::::::::@@@@@@@@@@@@@@@@@ 8 | @@@@:::::::::::::::::::::::::::@@@@@@@@@@@@@@@@@ 9 | @@@@@@:::::::::::++oo+:::::::::::::@@@@@@@@@@@@@ 10 | @@@@@@@@@:::::::+++oo+::::::::@@@@@@@@@@@@@@@@@@ 11 | @@@@::::::::::::+++++:::::::::::::@@@@@@@@@@@@@@ 12 | @@@@@@:::::::::::::::::::::::@@@@@@@@@@@@@@@@@@@ 13 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:::::@@@ 14 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::::::@@@@@@ 15 | @:::::::::::@@@@@@@@@@@@@@@@@@@@@@@:::::::::@@@@ 16 | @@@@:::::::@@@@@@@@@@@@@@@@@@@@@@@@@::::::::@@@@ 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | *.prg 17 | *.cbmprj 18 | *.dmp 19 | *.tmp 20 | bak/ 21 | 22 | # Windows shortcuts 23 | *.lnk 24 | 25 | # ========================= 26 | # Operating System Files 27 | # ========================= 28 | 29 | # OSX 30 | # ========================= 31 | 32 | .DS_Store 33 | .AppleDouble 34 | .LSOverride 35 | 36 | # Thumbnails 37 | ._* 38 | 39 | # Files that might appear in the root of a volume 40 | .DocumentRevisions-V100 41 | .fseventsd 42 | .Spotlight-V100 43 | .TemporaryItems 44 | .Trashes 45 | .VolumeIcon.icns 46 | 47 | # Directories potentially created on remote AFP share 48 | .AppleDB 49 | .AppleDesktop 50 | Network Trash Folder 51 | Temporary Items 52 | .apdisk 53 | 54 | -------------------------------------------------------------------------------- /bak/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | *.prg 17 | *.cbmprj 18 | *.dmp 19 | *.tmp 20 | bak/ 21 | 22 | # Windows shortcuts 23 | *.lnk 24 | 25 | # ========================= 26 | # Operating System Files 27 | # ========================= 28 | 29 | # OSX 30 | # ========================= 31 | 32 | .DS_Store 33 | .AppleDouble 34 | .LSOverride 35 | 36 | # Thumbnails 37 | ._* 38 | 39 | # Files that might appear in the root of a volume 40 | .DocumentRevisions-V100 41 | .fseventsd 42 | .Spotlight-V100 43 | .TemporaryItems 44 | .Trashes 45 | .VolumeIcon.icns 46 | 47 | # Directories potentially created on remote AFP share 48 | .AppleDB 49 | .AppleDesktop 50 | Network Trash Folder 51 | Temporary Items 52 | .apdisk 53 | 54 | -------------------------------------------------------------------------------- /bak/interrupt.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | sei 4 | lda #interrupt 7 | sta $315 8 | cli 9 | rts 10 | 11 | interrupt 12 | inc value 13 | lda value 14 | cmp #10 15 | bne @end 16 | lda #0 17 | sta value 18 | 19 | inc $400 20 | @end jmp $ea31 21 | 22 | value byte 00 23 | -------------------------------------------------------------------------------- /interrupt.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | sei 4 | lda #interrupt 7 | sta $315 8 | cli 9 | rts 10 | 11 | interrupt 12 | inc value 13 | lda value 14 | cmp #10 15 | bne @end 16 | lda #0 17 | sta value 18 | 19 | inc $400 20 | @end jmp $ea31 21 | 22 | value byte 00 23 | -------------------------------------------------------------------------------- /disk.asm: -------------------------------------------------------------------------------- 1 | *=$1000 ; just an example 2 | 3 | LDA #4 ; length of filename 4 | LDX #fname 6 | JSR $FFBD ; call SETNAM 7 | LDA #$01 8 | LDX $BA ; last used device number 9 | BNE skip 10 | LDX #$08 ; default to device 8 11 | skip LDY #$00 ; $00 means: load to new address 12 | JSR $FFBA ; call SETLFS 13 | 14 | LDX #load_address 16 | LDA #$00 ; $00 means: load to memory (not verify) 17 | JSR $FFD5 ; call LOAD 18 | BCS error ; if carry set, a load error has happened 19 | RTS 20 | error 21 | ; Accumulator contains BASIC error code 22 | 23 | ; most likely errors: 24 | ; A = $05 (DEVICE NOT PRESENT) 25 | ; A = $04 (FILE NOT FOUND) 26 | ; A = $1D (LOAD ERROR) 27 | ; A = $00 (BREAK, RUN/STOP has been pressed during loading) 28 | 29 | ;... error handling ... 30 | sta $400 31 | RTS 32 | 33 | fname TEXT "test" 34 | *=$2000 35 | load_address 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zef-Series 2 | C64 Programming Tutorial Series 3 | 4 | This is where I will be saving my source code for this tutorial series. These programs were written using the CBM Prg Studio by Arthur Jordison. 5 | 6 | Right now the source code consists of one basic program "zef.bas" and a few assembly language programs. 7 | 8 | The first one "zef1.asm" was my first cut at converting the basic program into assembler. The second one, "zef2.asm" is my optimized version. 9 | 10 | The third one "zef3.asm" expands upon the second one adding a redefined character set with a shifting character to create that "water" effect. 11 | 12 | There is a separate file "shifting.asm" which produces the shifting effect and interrupt in one source file. 13 | 14 | "interrupt.asm" provides a quick example of one way to code a program interrupt on the Commodore 64. 15 | 16 | "Window.asm" demonstrates a window scrolling technique. "window2.asm" adds in text output into the mix. 17 | 18 | In "zef4.asm" I integrate in the text printing program and text window scroll. 19 | 20 | In "zef5.asm" I added borders and colors to the project. 21 | 22 | In "zef6.asm" I added the player character, movement detection and "blocked" text. 23 | 24 | In "zef7.asm" I added a couple sound effects. Associated files are "SOUND_Move.asm" and "SOUND_Blocked.asm" 25 | 26 | In "zef8.asm" I optimized some code segments. 27 | 28 | In "zef9.asm" I added some code to load a new player map 29 | 30 | In "zef10.asm" I expand upon zef9.asm further fleshing out the code adding a new map and allowing entry from hash tag and asterisk characters. 31 | 32 | In "Zef11.asm" I implemented loading maps from disk. This is the final version for this project. 33 | -------------------------------------------------------------------------------- /bak/README.md: -------------------------------------------------------------------------------- 1 | # Zef-Series 2 | C64 Programming Tutorial Series 3 | 4 | This is where I will be saving my source code for this tutorial series. These programs were written using the CBM Prg Studio by Arthur Jordison. 5 | 6 | Right now the source code consists of one basic program "zef.bas" and a few assembly language programs. 7 | 8 | The first one "zef1.asm" was my first cut at converting the basic program into assembler. The second one, "zef2.asm" is my optimized version. 9 | 10 | The third one "zef3.asm" expands upon the second one adding a redefined character set with a shifting character to create that "water" effect. 11 | 12 | There is a separate file "shifting.asm" which produces the shifting effect and interrupt in one source file. 13 | 14 | "interrupt.asm" provides a quick example of one way to code a program interrupt on the Commodore 64. 15 | 16 | "Window.asm" demonstrates a window scrolling technique. "window2.asm" adds in text output into the mix. 17 | 18 | In "zef4.asm" I integrate in the text printing program and text window scroll. 19 | 20 | In "zef5.asm" I added borders and colors to the project. 21 | 22 | In "zef6.asm" I added the player character, movement detection and "blocked" text. 23 | 24 | In "zef7.asm" I added a couple sound effects. Associated files are "SOUND_Move.asm" and "SOUND_Blocked.asm" 25 | 26 | In "zef8.asm" I optimized some code segments. 27 | 28 | In "zef9.asm" I added some code to load a new player map 29 | 30 | In "zef10.asm" I expand upon zef9.asm further fleshing out the code adding a new map and allowing entry from hash tag and asterisk characters. 31 | 32 | In "Zef11.asm" I implemented loading maps from disk. This is the final version for this project. 33 | -------------------------------------------------------------------------------- /disk2.asm: -------------------------------------------------------------------------------- 1 | *=$1000 ; just an example 2 | 3 | LDA #4 ; length of filename 4 | LDX #fname 6 | JSR $FFBD ; call SETNAM 7 | 8 | LDA #$02 ; file number 2 9 | LDX $BA ; last used device number 10 | BNE .skip 11 | LDX #$08 ; default to device 8 12 | .skip LDY #$02 ; secondary address 2 13 | JSR $FFBA ; call SETLFS 14 | 15 | JSR $FFC0 ; call OPEN 16 | BCS .error ; if carry set, the file could not be opened 17 | 18 | ; check drive error channel here to test for 19 | ; FILE NOT FOUND error etc. 20 | 21 | LDX #$02 ; filenumber 2 22 | JSR $FFC6 ; call CHKIN (file 2 now used as input) 23 | 24 | LDA #load_address 27 | STA $AF 28 | 29 | LDY #$00 30 | .loop JSR $FFB7 ; call READST (read status byte) 31 | BNE .eof ; either EOF or read error 32 | JSR $FFCF ; call CHRIN (get a byte from file) 33 | STA ($AE),Y ; write byte to memory 34 | INC $AE 35 | BNE .skip2 36 | INC $AF 37 | .skip2 JMP .loop ; next byte 38 | 39 | .eof 40 | AND #$40 ; end of file? 41 | BEQ .readerror 42 | .close 43 | LDA #$02 ; filenumber 2 44 | JSR $FFC3 ; call CLOSE 45 | 46 | JSR $FFCC ; call CLRCHN 47 | RTS 48 | .error 49 | ; Akkumulator contains BASIC error code 50 | 51 | ; most likely errors: 52 | ; A = $05 (DEVICE NOT PRESENT) 53 | 54 | ;... error handling for open errors ... 55 | JMP .close ; even if OPEN failed, the file has to be closed 56 | .readerror 57 | ; for further information, the drive error channel has to be read 58 | 59 | ;... error handling for read errors ... 60 | JMP .close 61 | 62 | fname 63 | text "test" 64 | 65 | *=$2000 66 | load_address 67 | -------------------------------------------------------------------------------- /SOUND_Move.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | SND = 54272 3 | SB = 54296 4 | SOUND_Move 5 | @sound 6 | 7 | @sound2 8 | lda #15 9 | sta SND+24 10 | 11 | lda #8 12 | sta SND+1 13 | 14 | lda #15 15 | sta SND+5 16 | lda #%11110000 17 | sta SND+6 18 | lda #17 19 | sta SND+4 20 | 21 | ldy #13 22 | ldx #10 23 | jsr @WAVE_DOWN 24 | ldy #10 25 | ldx #13 26 | jsr @WAVE_UP 27 | lda #0 28 | sta SND+1 29 | rts 30 | @WAVE_UP 31 | stx @SM_1+1 32 | @loopab tya 33 | sta SND+1 34 | pha 35 | jsr @delay 36 | pla 37 | tay 38 | iny 39 | @SM_1 cpy #15 40 | bne @loopab 41 | rts 42 | @WAVE_DOWN 43 | stx @SM_2+1 44 | @loopabc tya 45 | sta SND+1 46 | pha 47 | jsr @delay 48 | pla 49 | tay 50 | dey 51 | @SM_2 cpy #15 52 | bne @loopabc 53 | rts 54 | 55 | @delay ldx #4 56 | @lp2 ldy #0 57 | @lp dey 58 | bne @lp 59 | dex 60 | bne @lp2 61 | rts 62 | 63 | @delay_more ldx #100 64 | @lp2a ldy #0 65 | @lpa dey 66 | bne @lpa 67 | dex 68 | bne @lp2a 69 | rts -------------------------------------------------------------------------------- /zef.bas: -------------------------------------------------------------------------------- 1 | 1000 rem ****************************************************** 2 | 1020 rem * Gray Defender 3 | 1040 rem * 04/07/2015 4 | 1060 rem * Zefeldar .01 basic version (the precursor) 5 | 1080 rem * This program will display information 6 | 1100 rem * from a viewport section of a string array 7 | 1120 rem * Then take input allowing the user to 'move' up 8 | 1140 rem * down, left or right. q to stop 9 | 1160 rem * the code will allow the viewport to wrap back around 10 | 1180 rem * in any direction. 11 | 1200 rem * a$ is the string array containing the entire 'map' 12 | 1220 rem * xx and yy are the width of the 'viewport' 13 | 1240 rem * cx,cy are the starting position, top left corner of the 14 | 1260 rem * 'viewport' within the string array 15 | 1280 rem * dx,dy are physical starting position on screen, top left corner of the 16 | 1300 rem * viewport on the c64 screen. Adjust these variables to move 17 | 1320 rem * the information displayed on the screen 18 | 1340 rem * This basic code is slow which is why it needs to rewriten 19 | 1360 rem * in asembly, using this code as a framework. 20 | 1370 rem * All positions starting with '0' 21 | 1380 rem ******************************************************* 22 | 1390 print chr$(147) 23 | 1400 dim a$(10) 24 | 1420 a$(0)="graydefenderttttttttccccccccccddddddddddffffffffff" 25 | 1440 a$(1)="testingoooggggggggggeeeeeeeeeerrrrrrrrrroooooooooo" 26 | 1460 a$(2)="helloworldyyyyyyyyyyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo" 27 | 1480 a$(3)="baaaaxxooojjjjjjjjjjxxiixxiixxxxxxxxxxxiiixxxxiixo" 28 | 1500 a$(4)="noxxxxxxooooooooooooiiixxxxxixaaaaaaxxxxxxxxxxxxxo" 29 | 1520 a$(5)="wooxxxxooommmmmmmmmmxxxxxxxxxxxxxxxiiiiiiiixxxxxxo" 30 | 1540 a$(6)="aooooooooxooooooooonxxxxxxxxxxxxxxxixxxxxxixxxxxxo" 31 | 1560 a$(7)="soooooooxxxxooooooowxxxxxxxxxxxxxxxixxxxxxixxxxxxo" 32 | 1580 a$(8)="aooooooxoooxooooooofxxxxxxxxxxxxxxxixxxxxxixxxxxxo" 33 | 1600 a$(9)="booooooxxxxxooooooocxxxxxxxxxxxxxxxxxxxxxxixxxxxxo" 34 | 1620 y=40 35 | 1640 xx=8 36 | 1660 yy=8 37 | 1680 cx=0 38 | 1700 cy=1 39 | 1720 dx=5 40 | 1740 dy=5 41 | 1750 wd=50 42 | 1760 gosub 1940 43 | 1780 a=peek(197) 44 | 1790 rem a, s =left and right w,z=up and down q=quit 45 | 1800 if a=10 then cx=cx-1:gosub 1940 46 | 1820 if a=13 then cx=cx+1:gosub 1940 47 | 1840 if a=9 then cy=cy-1:gosub 1940 48 | 1860 if a=12 then cy=cy+1:gosub 1940 49 | 1880 if a=62 then stop 50 | 1900 goto 1780 51 | 1910 rem 52 | 1920 rem 53 | 1940 if cy<0 then cy=9 54 | 1960 if cx<0 then cx=wd 55 | 1970 if cx>wd then cx=0 56 | 1975 if cy>9 then cy=0 57 | 1980 offset=1024+(dy*y)+dx-1 58 | 2000 for j=0 to yy-1 59 | 2020 ny=j+cy 60 | 2040 if ny>9 then ny=ny-10 61 | 2060 for i=1 to xx 62 | 2080 nx=i+cx 63 | 2100 if nx>wd then nx=nx-wd 64 | 2120 poke offset+i,asc(mid$(a$(ny),nx,1))-64 65 | 2140 next i 66 | 2160 offset=offset+y 67 | 2180 next j 68 | 2200 return 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /bak/zef.bas: -------------------------------------------------------------------------------- 1 | 1000 rem ****************************************************** 2 | 1020 rem * Gray Defender 3 | 1040 rem * 04/07/2015 4 | 1060 rem * Zefeldar .01 basic version (the precursor) 5 | 1080 rem * This program will display information 6 | 1100 rem * from a viewport section of a string array 7 | 1120 rem * Then take input allowing the user to 'move' up 8 | 1140 rem * down, left or right. q to stop 9 | 1160 rem * the code will allow the viewport to wrap back around 10 | 1180 rem * in any direction. 11 | 1200 rem * a$ is the string array containing the entire 'map' 12 | 1220 rem * xx and yy are the width of the 'viewport' 13 | 1240 rem * cx,cy are the starting position, top left corner of the 14 | 1260 rem * 'viewport' within the string array 15 | 1280 rem * dx,dy are physical starting position on screen, top left corner of the 16 | 1300 rem * viewport on the c64 screen. Adjust these variables to move 17 | 1320 rem * the information displayed on the screen 18 | 1340 rem * This basic code is slow which is why it needs to rewriten 19 | 1360 rem * in asembly, using this code as a framework. 20 | 1370 rem * All positions starting with '0' 21 | 1380 rem ******************************************************* 22 | 1390 print chr$(147) 23 | 1400 dim a$(10) 24 | 1420 a$(0)="graydefenderttttttttccccccccccddddddddddffffffffff" 25 | 1440 a$(1)="testingoooggggggggggeeeeeeeeeerrrrrrrrrroooooooooo" 26 | 1460 a$(2)="helloworldyyyyyyyyyyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo" 27 | 1480 a$(3)="baaaaxxooojjjjjjjjjjxxiixxiixxxxxxxxxxxiiixxxxiixo" 28 | 1500 a$(4)="noxxxxxxooooooooooooiiixxxxxixaaaaaaxxxxxxxxxxxxxo" 29 | 1520 a$(5)="wooxxxxooommmmmmmmmmxxxxxxxxxxxxxxxiiiiiiiixxxxxxo" 30 | 1540 a$(6)="aooooooooxooooooooonxxxxxxxxxxxxxxxixxxxxxixxxxxxo" 31 | 1560 a$(7)="soooooooxxxxooooooowxxxxxxxxxxxxxxxixxxxxxixxxxxxo" 32 | 1580 a$(8)="aooooooxoooxooooooofxxxxxxxxxxxxxxxixxxxxxixxxxxxo" 33 | 1600 a$(9)="booooooxxxxxooooooocxxxxxxxxxxxxxxxxxxxxxxixxxxxxo" 34 | 1620 y=40 35 | 1640 xx=8 36 | 1660 yy=8 37 | 1680 cx=0 38 | 1700 cy=1 39 | 1720 dx=5 40 | 1740 dy=5 41 | 1750 wd=50 42 | 1760 gosub 1940 43 | 1780 a=peek(197) 44 | 1790 rem a, s =left and right w,z=up and down q=quit 45 | 1800 if a=10 then cx=cx-1:gosub 1940 46 | 1820 if a=13 then cx=cx+1:gosub 1940 47 | 1840 if a=9 then cy=cy-1:gosub 1940 48 | 1860 if a=12 then cy=cy+1:gosub 1940 49 | 1880 if a=62 then stop 50 | 1900 goto 1780 51 | 1910 rem 52 | 1920 rem 53 | 1940 if cy<0 then cy=9 54 | 1960 if cx<0 then cx=wd 55 | 1970 if cx>wd then cx=0 56 | 1975 if cy>9 then cy=0 57 | 1980 offset=1024+(dy*y)+dx-1 58 | 2000 for j=0 to yy-1 59 | 2020 ny=j+cy 60 | 2040 if ny>9 then ny=ny-10 61 | 2060 for i=1 to xx 62 | 2080 nx=i+cx 63 | 2100 if nx>wd then nx=nx-wd 64 | 2120 poke offset+i,asc(mid$(a$(ny),nx,1))-64 65 | 2140 next i 66 | 2160 offset=offset+y 67 | 2180 next j 68 | 2200 return 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /charset.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 4 | 5 | Character_Set 6 | sei ; disable interrupts while we copy 7 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 8 | lda #$33 ; make the CPU see the Character Generator ROM... 9 | sta $01 ; ...at $D000 by storing %00110011 into location $01 10 | lda #$d0 ; load high byte of $D000 11 | sta $fc ; store it in a free location we use as vector 12 | LDA #$30 ; 13 | STA $fe ; 14 | LDA #0 ; 15 | STA $fd 16 | ldy #$00 ; init counter with 0 17 | sty $fb ; store it as low byte in the $FB/$FC vector 18 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 19 | sta ($fd),y ; write to the RAM under ROM at same position 20 | iny ; do this 255 times... 21 | bne loop ; ..for low byte $00 to $FF 22 | inc $fc ; when we passed $FF increase high byte... 23 | inc $fe 24 | dex ; ... and decrease X by one before restart 25 | bne loop ; We repeat this until X becomes Zero 26 | lda #$37 ; switch in I/O mapped registers again... 27 | sta $01 ; ... with %00110111 so CPU can see them 28 | cli ; turn off interrupt disable flag 29 | LDA #28 30 | STA $d018 ; 31 | 32 | ; *********************************************************************************** 33 | ; 34 | 35 | ldy #0 36 | @loop tya 37 | sta $400,y 38 | sta $500,y 39 | sta $600,y 40 | sta $700,y 41 | dey 42 | bne @loop 43 | 44 | lda #0 ; Redefine one character 45 | sta $3000 46 | sta $3001 47 | rts 48 | 49 | 50 | -------------------------------------------------------------------------------- /xxx.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | 4 | ; lda #$31 5 | ; jsr $ffd2 6 | ; ldx #1 7 | ; jsr $e9ff 8 | ; clc 9 | ; ldx #10 10 | ; ldy #10 11 | ; jsr $fff0 12 | ; lda #$32 13 | ; jsr $ffd2 14 | 15 | ; jsr $ffed 16 | ; stx $400 17 | ; sty $401 18 | 19 | ; clc 20 | ldy POS_Y 21 | iny 22 | clc 23 | lda POS_X 24 | adc WD 25 | sta @new_compare+1 26 | sta @new_compare2+1 27 | clc 28 | lda POS_Y 29 | adc HT 30 | sta @new_compare3+1 31 | @loop ldx POS_X 32 | lda Const_Screen_H,y 33 | sta @screen1+2 34 | lda Const_Screen_L,y 35 | sta @screen1+1 36 | dey 37 | lda Const_Screen_H,y 38 | sta @screen2+2 39 | lda Const_Screen_L,y 40 | sta @screen2+1 41 | iny 42 | @screen1 lda $428,x 43 | @screen2 sta $400,x 44 | inx 45 | @new_compare cpx #10 46 | bne @screen1 47 | iny 48 | @new_compare3 cpy #10 49 | bne @loop 50 | 51 | dey 52 | lda Const_Screen_H,y 53 | sta @loop2+2 54 | lda Const_Screen_L,y 55 | sta @loop2+1 56 | ldx POS_X 57 | lda #$20 58 | @loop2 sta $400,x 59 | inx 60 | @new_compare2 cpx #10 61 | bne @loop2 62 | rts 63 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 64 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 65 | POS_X byte 15 66 | POS_Y byte 5 67 | WD byte 10 68 | HT byte 10 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /bak/xxx.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | 4 | ; lda #$31 5 | ; jsr $ffd2 6 | ; ldx #1 7 | ; jsr $e9ff 8 | ; clc 9 | ; ldx #10 10 | ; ldy #10 11 | ; jsr $fff0 12 | ; lda #$32 13 | ; jsr $ffd2 14 | 15 | ; jsr $ffed 16 | ; stx $400 17 | ; sty $401 18 | 19 | ; clc 20 | ldy POS_Y 21 | iny 22 | clc 23 | lda POS_X 24 | adc WD 25 | sta @new_compare+1 26 | sta @new_compare2+1 27 | clc 28 | lda POS_Y 29 | adc HT 30 | sta @new_compare3+1 31 | @loop ldx POS_X 32 | lda Const_Screen_H,y 33 | sta @screen1+2 34 | lda Const_Screen_L,y 35 | sta @screen1+1 36 | dey 37 | lda Const_Screen_H,y 38 | sta @screen2+2 39 | lda Const_Screen_L,y 40 | sta @screen2+1 41 | iny 42 | @screen1 lda $428,x 43 | @screen2 sta $400,x 44 | inx 45 | @new_compare cpx #10 46 | bne @screen1 47 | iny 48 | @new_compare3 cpy #10 49 | bne @loop 50 | 51 | dey 52 | lda Const_Screen_H,y 53 | sta @loop2+2 54 | lda Const_Screen_L,y 55 | sta @loop2+1 56 | ldx POS_X 57 | lda #$20 58 | @loop2 sta $400,x 59 | inx 60 | @new_compare2 cpx #10 61 | bne @loop2 62 | rts 63 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 64 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 65 | POS_X byte 15 66 | POS_Y byte 5 67 | WD byte 10 68 | HT byte 10 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /window.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | defm store_values ; This macro loads first 4 | lda /1,y ; param then stores in 5 | sta /2 ; second param 6 | lda /3,y ; the loads third and 7 | sta /4 ; stores in forth 8 | endm 9 | 10 | defm shift_window 11 | lda /1 12 | sta WIN_X 13 | lda /2 14 | sta WIN_Y 15 | lda /3 16 | sta WD 17 | lda /4 18 | sta HT 19 | jsr Scroll_Window_Up 20 | endm 21 | 22 | shift_window #5,#0,#10,#5 23 | 24 | 25 | rts 26 | 27 | Scroll_Window_Up 28 | ldy WIN_Y 29 | iny 30 | clc 31 | lda WIN_X 32 | adc WD 33 | sta MAX_WIDTH 34 | clc 35 | lda WIN_Y 36 | adc HT 37 | sta max_ht+1 38 | loop ldx WIN_X 39 | store_values Const_Screen_H,input+2,Const_Screen_L,input+1 40 | store_values Const_Screen_H,lastline+2,Const_Screen_L,lastline+1 41 | dey 42 | store_values Const_Screen_H,output+2,Const_Screen_L,output+1 43 | iny 44 | input lda $428,x 45 | output sta $400,x 46 | lda #$20 47 | lastline sta $428,x 48 | inx 49 | cpx MAX_WIDTH 50 | bne input 51 | iny 52 | max_ht cpy #10 53 | bne loop 54 | rts 55 | 56 | 57 | string null ">NORTH" 58 | string_pos byte 00 59 | ;********************************* 60 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 61 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 62 | WIN_X byte 0 63 | WIN_Y byte 0 64 | WD byte 40 65 | HT byte 25 66 | MAX_WIDTH byte 00 ; Starting position plus width of window 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /bak/window.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | defm store_values ; This macro loads first 4 | lda /1,y ; param then stores in 5 | sta /2 ; second param 6 | lda /3,y ; the loads third and 7 | sta /4 ; stores in forth 8 | endm 9 | 10 | defm shift_window 11 | lda /1 12 | sta WIN_X 13 | lda /2 14 | sta WIN_Y 15 | lda /3 16 | sta WD 17 | lda /4 18 | sta HT 19 | jsr Scroll_Window_Up 20 | endm 21 | 22 | shift_window #5,#0,#10,#5 23 | 24 | 25 | rts 26 | 27 | Scroll_Window_Up 28 | ldy WIN_Y 29 | iny 30 | clc 31 | lda WIN_X 32 | adc WD 33 | sta MAX_WIDTH 34 | clc 35 | lda WIN_Y 36 | adc HT 37 | sta max_ht+1 38 | loop ldx WIN_X 39 | store_values Const_Screen_H,input+2,Const_Screen_L,input+1 40 | store_values Const_Screen_H,lastline+2,Const_Screen_L,lastline+1 41 | dey 42 | store_values Const_Screen_H,output+2,Const_Screen_L,output+1 43 | iny 44 | input lda $428,x 45 | output sta $400,x 46 | lda #$20 47 | lastline sta $428,x 48 | inx 49 | cpx MAX_WIDTH 50 | bne input 51 | iny 52 | max_ht cpy #10 53 | bne loop 54 | rts 55 | 56 | 57 | string null ">NORTH" 58 | string_pos byte 00 59 | ;********************************* 60 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 61 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 62 | WIN_X byte 0 63 | WIN_Y byte 0 64 | WD byte 40 65 | HT byte 25 66 | MAX_WIDTH byte 00 ; Starting position plus width of window 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /SOUND_Blocked.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | SND = 54272 3 | SB = 54296 4 | SND_BEG = 9 5 | SND_END = 12 6 | SOUND_Blocked 7 | @sound 8 | 9 | @sound2 10 | lda #15 11 | sta SND+24 12 | 13 | lda #8 14 | sta SND+1 15 | 16 | lda #15 17 | sta SND+5 18 | lda #%11110000 19 | sta SND+6 20 | lda #17 21 | sta SND+4 22 | 23 | ldy #SND_BEG 24 | ldx #SND_END 25 | jsr @WAVE_UP 26 | ldy #SND_BEG 27 | ldx #SND_END 28 | jsr @WAVE_UP 29 | ldy #SND_BEG 30 | ldx #SND_END 31 | jsr @WAVE_UP 32 | ldy #SND_BEG 33 | ldx #SND_END 34 | jsr @WAVE_UP 35 | 36 | lda #0 37 | sta SND+1 38 | 39 | ldx #50 40 | jsr @delay+2 41 | lda #8 42 | sta SND+1 43 | 44 | ldy #SND_BEG 45 | ldx #SND_END 46 | jsr @WAVE_UP 47 | ldy #SND_BEG 48 | ldx #SND_END 49 | jsr @WAVE_UP 50 | ldy #SND_BEG 51 | ldx #SND_END 52 | jsr @WAVE_UP 53 | ldy #SND_BEG 54 | ldx #SND_END 55 | jsr @WAVE_UP 56 | 57 | lda #0 58 | sta SND+1 59 | rts 60 | @WAVE_UP 61 | stx @SM_1+1 62 | @loopab tya 63 | sta SND+1 64 | pha 65 | jsr @delay 66 | pla 67 | tay 68 | iny 69 | @SM_1 cpy #15 70 | bne @loopab 71 | rts 72 | @WAVE_DOWN 73 | stx @SM_2+1 74 | @loopabc tya 75 | sta SND+1 76 | pha 77 | jsr @delay 78 | pla 79 | tay 80 | dey 81 | @SM_2 cpy #15 82 | bne @loopabc 83 | rts 84 | 85 | @delay ldx #4 86 | @lp2 ldy #0 87 | @lp dey 88 | bne @lp 89 | dex 90 | bne @lp2 91 | rts 92 | 93 | @delay_more ldx #100 94 | @lp2a ldy #0 95 | @lpa dey 96 | bne @lpa 97 | dex 98 | bne @lp2a 99 | rts -------------------------------------------------------------------------------- /window2.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | 3 | defm store_values ; This macro loads first 4 | lda /1,y ; param then stores in 5 | sta /2 ; second param 6 | lda /3,y ; the loads third and 7 | sta /4 ; stores in forth 8 | endm 9 | 10 | defm shift_window 11 | lda /1 12 | sta WIN_X 13 | lda /2 14 | sta WIN_Y 15 | lda /3 16 | sta WD 17 | lda /4 18 | sta HT 19 | jsr Scroll_Window_Up 20 | endm 21 | 22 | defm Print_Text 23 | 24 | lda #/1 27 | sta main_string+2 28 | jsr Display_Text 29 | endm 30 | 31 | shift_window #5,#15,#10,#5 32 | Print_Text str_north 33 | 34 | rts 35 | 36 | Scroll_Window_Up 37 | ldy WIN_Y 38 | iny 39 | clc 40 | lda WIN_X 41 | adc WD 42 | sta MAX_WIDTH 43 | clc 44 | lda WIN_Y 45 | adc HT 46 | sta max_ht+1 47 | loop ldx WIN_X 48 | store_values Const_Screen_H,input+2,Const_Screen_L,input+1 49 | store_values Const_Screen_H,lastline+2,Const_Screen_L,lastline+1 50 | dey 51 | store_values Const_Screen_H,output+2,Const_Screen_L,output+1 52 | iny 53 | input lda $428,x 54 | output sta $400,x 55 | lda #$20 56 | lastline sta $428,x 57 | inx 58 | cpx MAX_WIDTH 59 | bne input 60 | iny 61 | max_ht cpy #10 62 | bne loop 63 | rts 64 | 65 | Display_Text 66 | lda #0 67 | sta string_pos 68 | Top_loop clc ; Set Cursor Position 69 | ldx max_ht+1 ; 70 | dex ; 71 | ldy WIN_X ; 72 | jsr $e50a ; X=Row, Y=Column 73 | ldx #0 74 | loop123 ldy string_pos 75 | main_string lda $ffff,y 76 | beq @exit_loop 77 | jsr $ffd2 78 | inx 79 | inc string_pos 80 | cpx WD 81 | bne loop123 82 | jsr Scroll_Window_Up 83 | jmp Top_loop 84 | @exit_loop 85 | rts 86 | str_north null ">NORTH" 87 | string_pos byte 00 88 | ;********************************* 89 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 90 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 91 | WIN_X byte 0 92 | WIN_Y byte 0 93 | WD byte 40 94 | HT byte 25 95 | MAX_WIDTH byte 00 ; Starting position plus width of window 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /shifting.asm: -------------------------------------------------------------------------------- 1 | *=$0801 2 | byte $0c, $08, $0a, $00, $9e, $20 3 | byte $34, $30, $39, $36, $00, $00 4 | byte $00 5 | 6 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 7 | 8 | *=$1000 9 | sei ; disable interrupts while we copy 10 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 11 | lda #$33 ; make the CPU see the Character Generator ROM... 12 | sta $01 ; ...at $D000 by storing %00110011 into location $01 13 | lda #$d0 ; load high byte of $D000 14 | sta $fc ; store it in a free location we use as vector 15 | LDA #$30 ; 16 | STA $fe ; 17 | LDA #0 ; 18 | STA $fd 19 | ldy #$00 ; init counter with 0 20 | sty $fb ; store it as low byte in the $FB/$FC vector 21 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 22 | sta ($fd),y ; write to the RAM under ROM at same position 23 | iny ; do this 255 times... 24 | bne loop ; ..for low byte $00 to $FF 25 | inc $fc ; when we passed $FF increase high byte... 26 | inc $fe 27 | dex ; ... and decrease X by one before restart 28 | bne loop ; We repeat this until X becomes Zero 29 | lda #$37 ; switch in I/O mapped registers again... 30 | sta $01 ; ... with %00110111 so CPU can see them 31 | cli ; turn off interrupt disable flag 32 | LDA #28 33 | ; 34 | STA $d018 ; 35 | 36 | ; *********************************************************************************** 37 | ; 38 | 39 | ldx #0 40 | @loop lda water,x 41 | sta $3000,x 42 | inx 43 | cpx #8 44 | bne @loop 45 | 46 | lda #0 47 | sta $400 48 | 49 | ; 50 | setup = * 51 | sei ; disable interrupts 52 | lda #intcode ; do the same with the high byte 55 | sta 789 56 | cli ; re-enable interrupts 57 | rts ; return to caller 58 | intcode = * 59 | inc value 60 | lda value 61 | cmp #$a 62 | bne end 63 | lda #0 64 | sta value 65 | lda $3000 66 | sta temp 67 | lda $3001 68 | sta $3000 69 | lda $3002 70 | sta $3001 71 | lda $3003 72 | sta $3002 73 | lda $3004 74 | sta $3003 75 | lda $3005 76 | sta $3004 77 | lda $3006 78 | sta $3005 79 | lda $3007 80 | sta $3006 81 | lda temp 82 | sta $3007 83 | end jmp $ea31 84 | temp byte 00 85 | value byte 00 86 | 87 | 88 | ;water BYTE $C6,$31,$8C,$43,$30,$8C,$63,$18 89 | water BYTE $30,$0C,$03,$C0,$30,$0C,$03,$C0 90 | ;water BYTE $7E,$81,$7E,$81,$7E,$81,$7E,$81 91 | ;water BYTE $DC,$23,$DC,$22,$9D,$62,$9C,$23 92 | ;water BYTE $F0,$0F,$F0,$0F,$F0,$0F,$F0,$0F 93 | ;water BYTE $CC,$33,$CC,$33,$CC,$33,$CC,$33 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /bak/shifting.asm: -------------------------------------------------------------------------------- 1 | *=$0801 2 | byte $0c, $08, $0a, $00, $9e, $20 3 | byte $34, $30, $39, $36, $00, $00 4 | byte $00 5 | 6 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 7 | 8 | *=$1000 9 | sei ; disable interrupts while we copy 10 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 11 | lda #$33 ; make the CPU see the Character Generator ROM... 12 | sta $01 ; ...at $D000 by storing %00110011 into location $01 13 | lda #$d0 ; load high byte of $D000 14 | sta $fc ; store it in a free location we use as vector 15 | LDA #$30 ; 16 | STA $fe ; 17 | LDA #0 ; 18 | STA $fd 19 | ldy #$00 ; init counter with 0 20 | sty $fb ; store it as low byte in the $FB/$FC vector 21 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 22 | sta ($fd),y ; write to the RAM under ROM at same position 23 | iny ; do this 255 times... 24 | bne loop ; ..for low byte $00 to $FF 25 | inc $fc ; when we passed $FF increase high byte... 26 | inc $fe 27 | dex ; ... and decrease X by one before restart 28 | bne loop ; We repeat this until X becomes Zero 29 | lda #$37 ; switch in I/O mapped registers again... 30 | sta $01 ; ... with %00110111 so CPU can see them 31 | cli ; turn off interrupt disable flag 32 | LDA #28 33 | ; 34 | STA $d018 ; 35 | 36 | ; *********************************************************************************** 37 | ; 38 | 39 | ldx #0 40 | @loop lda water,x 41 | sta $3000,x 42 | inx 43 | cpx #8 44 | bne @loop 45 | 46 | lda #0 47 | sta $400 48 | 49 | ; 50 | setup = * 51 | sei ; disable interrupts 52 | lda #intcode ; do the same with the high byte 55 | sta 789 56 | cli ; re-enable interrupts 57 | rts ; return to caller 58 | intcode = * 59 | inc value 60 | lda value 61 | cmp #$a 62 | bne end 63 | lda #0 64 | sta value 65 | lda $3000 66 | sta temp 67 | lda $3001 68 | sta $3000 69 | lda $3002 70 | sta $3001 71 | lda $3003 72 | sta $3002 73 | lda $3004 74 | sta $3003 75 | lda $3005 76 | sta $3004 77 | lda $3006 78 | sta $3005 79 | lda $3007 80 | sta $3006 81 | lda temp 82 | sta $3007 83 | end jmp $ea31 84 | temp byte 00 85 | value byte 00 86 | 87 | 88 | ;water BYTE $C6,$31,$8C,$43,$30,$8C,$63,$18 89 | water BYTE $30,$0C,$03,$C0,$30,$0C,$03,$C0 90 | ;water BYTE $7E,$81,$7E,$81,$7E,$81,$7E,$81 91 | ;water BYTE $DC,$23,$DC,$22,$9D,$62,$9C,$23 92 | ;water BYTE $F0,$0F,$F0,$0F,$F0,$0F,$F0,$0F 93 | ;water BYTE $CC,$33,$CC,$33,$CC,$33,$CC,$33 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /drawmap.asm: -------------------------------------------------------------------------------- 1 | *=$1000 2 | jsr drawmap 3 | rts 4 | drawmap 5 | lda #$00 6 | sta scr_data+1 7 | lda #04 8 | sta scr_data+2 9 | lda #MAP_DATA 12 | sta gamemap+2 13 | 14 | ldx #4 15 | main_lp ldy #$00 16 | gamemap lda $ffff,y ; Load from the map 17 | scr_data sta $0400,y ; Store on the screen 18 | dey 19 | bne gamemap 20 | inc scr_data+2 21 | inc gamemap+2 22 | dex 23 | bne main_lp 24 | rts 25 | 26 | MAP_DATA 27 | BYTE $56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56 28 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 29 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 30 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 31 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 32 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 33 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 34 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 35 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 36 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 37 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 38 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 39 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 40 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 41 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 42 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 43 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 44 | BYTE $56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56 45 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 46 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 47 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 48 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 49 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 50 | BYTE $56,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$56 51 | BYTE $56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56,$56 -------------------------------------------------------------------------------- /zefscreen.sdd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 3 6 | 25 7 | 40 8 | 0 9 | 0 10 | 11 | 77 12 | 67 13 | 07 14 | 77 15 | True 16 | 17 | 18 | 0 19 | 7 20 | 7 21 | 7 22 | 7 23 | 7 24 | 6 25 | 14 26 | 7 27 | 7 28 | 6 29 | 0 30 | 7 31 | 5 32 | 560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767 33 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2003767,560F767,2006700,2006700,2006700,2006700,2001700,2001767,2001767,2001767,2001767,2001767,2001767,2001767,2001767,2006700,2006700,2006700,2006700,2006700,560F767 34 | 560F767,200C767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2003767,560F767,2006700,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,560F767 35 | 560F767,200C767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2003767,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 36 | 560F767,200C767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,560F767 37 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 38 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,560F767 39 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 40 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,0007767,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 41 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006767,2006767,2006767,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 42 | 560F767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 43 | 560F767,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 44 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2003767,2003767,560F767,2003767,2003700,2003700,2003700,2003700,2003700,2003700,2006700,2006767,2006767,2006700,2006700,2006700,2003767,2003767,2003767,2003767,2003767,560F767 45 | 560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,560F767 46 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2003700,2003700,2003700,560F767,2003767,2003700,2003700,2003700,2003700,2003700,2003700,2003700,2003767,2003700,2006700,2006700,200C767,200C767,200C767,200C767,200C767,2006767,560F767 47 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 48 | 560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 49 | 560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767 50 | 560F767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 51 | 560F767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 52 | 560F767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 53 | 560F767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 54 | 560F767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 55 | 560F767,2007767,2007700,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 56 | 560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767 57 | 58 | 59 | 60 | 0 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /bak/zefscreen.sdd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 3 6 | 25 7 | 40 8 | 0 9 | 0 10 | 11 | 77 12 | 67 13 | 07 14 | 77 15 | True 16 | 17 | 18 | 0 19 | 7 20 | 7 21 | 7 22 | 7 23 | 7 24 | 6 25 | 14 26 | 7 27 | 7 28 | 6 29 | 0 30 | 7 31 | 5 32 | 560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767 33 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2003767,560F767,2006700,2006700,2006700,2006700,2001700,2001767,2001767,2001767,2001767,2001767,2001767,2001767,2001767,2006700,2006700,2006700,2006700,2006700,560F767 34 | 560F767,200C767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2003767,560F767,2006700,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,560F767 35 | 560F767,200C767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2003767,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 36 | 560F767,200C767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,560F767 37 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 38 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,560F767 39 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 40 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,0007767,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 41 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006767,2006767,2006767,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 42 | 560F767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006767,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 43 | 560F767,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 44 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2003767,2003767,560F767,2003767,2003700,2003700,2003700,2003700,2003700,2003700,2006700,2006767,2006767,2006700,2006700,2006700,2003767,2003767,2003767,2003767,2003767,560F767 45 | 560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,560F767 46 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2003700,2003700,2003700,560F767,2003767,2003700,2003700,2003700,2003700,2003700,2003700,2003700,2003767,2003700,2006700,2006700,200C767,200C767,200C767,200C767,200C767,2006767,560F767 47 | 560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 48 | 560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,560F767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2003767,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,2006700,560F767 49 | 560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767 50 | 560F767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 51 | 560F767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 52 | 560F767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 53 | 560F767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 54 | 560F767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 55 | 560F767,2007767,2007700,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007767,2007767,2007767,2007767,2007767,2007767,2007700,2007700,2007700,2007767,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,2007700,560F767 56 | 560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767,560F767 57 | 58 | 59 | 60 | 0 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /charset2.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | *=$0801 4 | 5 | BYTE $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00 6 | 7 | ; [CODE START] ---------------------------------------------------------------- 8 | 9 | *=$0810 10 | 11 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 12 | 13 | Character_Set 14 | sei ; disable interrupts while we copy 15 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 16 | lda #$33 ; make the CPU see the Character Generator ROM... 17 | sta $01 ; ...at $D000 by storing %00110011 into location $01 18 | lda #$d0 ; load high byte of $D000 19 | sta $fc ; store it in a free location we use as vector 20 | LDA #$30 ; 21 | STA $fe ; 22 | LDA #0 ; 23 | STA $fd 24 | ldy #$00 ; init counter with 0 25 | sty $fb ; store it as low byte in the $FB/$FC vector 26 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 27 | sta ($fd),y ; write to the RAM under ROM at same position 28 | iny ; do this 255 times... 29 | bne loop ; ..for low byte $00 to $FF 30 | inc $fc ; when we passed $FF increase high byte... 31 | inc $fe 32 | dex ; ... and decrease X by one before restart 33 | bne loop ; We repeat this until X becomes Zero 34 | lda #$37 ; switch in I/O mapped registers again... 35 | sta $01 ; ... with %00110111 so CPU can see them 36 | cli ; turn off interrupt disable flag 37 | LDA #28 38 | STA $d018 ; 39 | 40 | ; *********************************************************************************** 41 | ; 42 | sei 43 | lda #0 44 | sta $d020 45 | sta $d021 46 | jsr initStarfield 47 | jsr CreateStarScreen ; Initialise Starfield 48 | 49 | 50 | 51 | Main 52 | 53 | @w1 bit $d011 ; Wait for Raster to be off screen 54 | bpl @w1 55 | @w2 bit $d011 56 | bmi @w2 57 | inc rasterCount 58 | jsr DoStarfield 59 | 60 | jmp Main 61 | 62 | 63 | ; Starfield.asm 64 | ; Jay Aldred 2017. 65 | 66 | 67 | ; 2 x 25 char arrays for starfield 68 | ; 1) f9d0 = start . fa97 = end (from char 58 to 107) 69 | ; 2) fa98 = start . fb5f = end 70 | 71 | 72 | starScreenChar = $0400 73 | StarScreenCols = $d800 74 | 75 | starfieldPtr = $f0 76 | starfieldPtr2 = $f2 77 | starfieldPtr3 = $f4 78 | starfieldPtr4 = $f6 79 | 80 | zeroPointer = $f8 81 | 82 | rasterCount = $fa 83 | 84 | 85 | staticStar1 = $3250 86 | staticStar2 = $31e0 87 | 88 | 89 | DoStarfield 90 | 91 | ; Erase it 92 | lda #0 93 | tay 94 | sta (starfieldPtr),y 95 | sta (starfieldPtr2),y 96 | sta (starfieldPtr3),y 97 | sta (starfieldPtr4),y 98 | ; *********************************** 99 | lda rasterCount 100 | and #1 101 | beq @star1 102 | inc starfieldPtr 103 | bne @ok 104 | inc starfieldPtr+1 105 | @ok 106 | lda starfieldPtr 107 | cmp #$98 108 | bne @star1 109 | lda starfieldPtr+1 110 | cmp #$32 111 | bne @star1 112 | lda #$d0 ; Reset 1 113 | sta starfieldPtr 114 | lda #$31 115 | sta starfieldPtr+1 116 | @star1 117 | ; *********************************** 118 | inc starfieldPtr2 119 | bne @ok2 120 | inc starfieldPtr2+1 121 | @ok2 122 | lda starfieldPtr2 123 | cmp #$60 124 | bne @star2 125 | lda starfieldPtr2+1 126 | cmp #$33 127 | bne @star2 128 | lda #$98 ; Reset 2 129 | sta starfieldPtr2 130 | lda #$32 131 | sta starfieldPtr2+1 132 | @star2 133 | ; *********************************** 134 | lda rasterCount 135 | and #1 136 | beq @star3 137 | inc starfieldPtr3 138 | bne @ok3 139 | inc starfieldPtr3+1 140 | @ok3 141 | lda starfieldPtr3 142 | cmp #$98 143 | bne @star3 144 | lda starfieldPtr3+1 145 | cmp #$32 146 | bne @star3 147 | lda #$d0 ; Reset 1 148 | sta starfieldPtr3 149 | lda #$31 150 | sta starfieldPtr3+1 151 | @star3 152 | ; *********************************** 153 | lda starfieldPtr4 154 | clc 155 | adc #2 156 | sta starfieldPtr4 157 | bcc @ok4 158 | inc starfieldPtr4+1 159 | @ok4 160 | lda starfieldPtr4+1 161 | cmp #$33 162 | bne @star4 163 | lda starfieldPtr4 164 | cmp #$60 165 | bcc @star4 166 | lda #$98 ; Reset 2 167 | sta starfieldPtr4 168 | lda #$32 169 | sta starfieldPtr4+1 170 | @star4 171 | ;; *********************************** 172 | 173 | ; Draw it! 174 | 175 | lda #192 ; 2 static stars that flicker 176 | ldy rasterCount 177 | cpy #230 178 | bcc @show 179 | lda #0 180 | @show sta staticStar1 ;$fa50 181 | 182 | tya 183 | eor #$80 184 | tay 185 | lda #192 186 | cpy #230 187 | bcc @show2 188 | lda #0 189 | @show2 sta staticStar2 ;$f9e0 190 | 191 | ldy #0 192 | lda (starfieldPtr),y ; Moving stars dont overlap other stars 193 | ora #3 194 | sta (starfieldPtr),y 195 | 196 | lda (starfieldPtr2),y 197 | ora #3 198 | sta (starfieldPtr2),y 199 | 200 | lda (starfieldPtr3),y 201 | ora #12 202 | sta (starfieldPtr3),y 203 | 204 | lda (starfieldPtr4),y 205 | ora #48 206 | sta (starfieldPtr4),y 207 | 208 | rts 209 | 210 | 211 | 212 | 213 | initStarfield 214 | lda #$d0 ; Reset 1 215 | sta starfieldPtr 216 | lda #$31 217 | sta starfieldPtr+1 218 | 219 | lda #$98 ; Reset 2 220 | sta starfieldPtr2 221 | lda #$32 222 | sta starfieldPtr2+1 223 | 224 | lda #$40 ; Reset 1 225 | sta starfieldPtr3 226 | lda #$32 227 | sta starfieldPtr3+1 228 | 229 | lda #$e0 ; Reset 2 230 | sta starfieldPtr4 231 | lda #$32 232 | sta starfieldPtr4+1 233 | 234 | rts 235 | 236 | 237 | 238 | ; [Create Star Screen] -------------------------------------------------------- 239 | 240 | ; Creates the starfield charmap and colour charmap 241 | 242 | CreateStarScreen 243 | ldx #40-1 ; Create starfield of chars 244 | @lp txa 245 | pha 246 | tay 247 | lda StarfieldRow,x 248 | 249 | sta @smc1+1 250 | ldx #58+25 251 | cmp #58+25 252 | bcc @low 253 | ldx #58+50 254 | @low stx @smc3+1 255 | txa 256 | sec 257 | sbc #25 258 | sta @smc2+1 259 | lda #starScreenChar 262 | sta zeroPointer+1 263 | ldx #25-1 264 | @smc1 lda #3 265 | sta (zeropointer),y 266 | lda zeropointer 267 | clc 268 | adc #40 269 | sta zeropointer 270 | bcc @clr 271 | inc zeropointer+1 272 | @clr inc @smc1+1 273 | lda @smc1+1 274 | @smc3 cmp #0 275 | bne @onscreen 276 | @smc2 lda #0 277 | sta @smc1+1 278 | @onscreen 279 | dex 280 | bpl @smc1 281 | 282 | pla 283 | tax 284 | dex 285 | bpl @lp 286 | 287 | lda #StarScreenCols 290 | sta zeroPointer+1 291 | ldx #25-1 292 | @lp1 stx @smcx+1 293 | ldx #0 294 | ldy #40-1 295 | @lp2 296 | lda starfieldCols,x 297 | sta (zeroPointer),y 298 | inx 299 | @smcz cpx #20 ; Loop around 'starfieldCols' 300 | bne @col 301 | ldx #0 302 | @col 303 | dey 304 | bpl @lp2 305 | lda zeroPointer 306 | clc 307 | adc #40 308 | sta zeroPointer 309 | bcc @hiOk 310 | inc zeroPointer+1 311 | @hiOk 312 | @smcx 313 | ldx #0 314 | dex 315 | bpl @lp1 316 | rts 317 | 318 | 319 | starColLimit = @smcz+1 320 | 321 | ; Dark starfield so it doesnt distract from bullets and text 322 | starfieldCols 323 | 324 | byte 14,10,12,15,14,13,12,11,10,14 325 | byte 14,10,14,15,14,13,12,11,10,12 326 | 327 | ; byte 14,10,14,13,10,12,14,10,12,14 328 | ; byte 11,12,14,10,12,14,15,10,12,14 329 | 330 | ; Star positions, 40 X positions, range 58-107 331 | starfieldRow 332 | byte 058,092,073,064,091,062,093,081,066,094 333 | byte 086,059,079,087,080,071,076,067,082,095 334 | byte 100,078,099,060,075,063,084,065,083,096 335 | byte 068,088,074,061,090,098,085,101,097,077 336 | 337 | 338 | 339 | 340 | -------------------------------------------------------------------------------- /zef2.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; Revised 4 | ; 4/20/2017 5 | ; Rewrote part of the program that displays data on the screen 6 | ; tried to make it more efficient 7 | ; Changed input routine to read kbd from $c5 8 | ;============================================================ 9 | ; Quick code to create auto execute program from basic 10 | ;============================================================ 11 | 12 | *=$0801 13 | byte $0c, $08, $0a, $00, $9e, $20 14 | byte $34, $30, $39, $36, $00, $00 15 | byte $00 16 | ;============================================================ 17 | ; Adjustable Variables and constants 18 | ;============================================================ 19 | Const_SCREEN_WD = #40 ;text width of screen (c64) 20 | Const_SCN_View_WD = #15 ;width of view port (viewable on screen) 21 | Const_SCN_View_HT = #10 ;height of view port (viewable on screen) 22 | Const_gmap_width = 40 ;Width of game map data 23 | Const_gmap_height = 10 ;Height of game map data 24 | vx byte 5 ;Starting x position into the game map data 25 | vy byte 5 ;Starting y position into the game map data 26 | ;============================================================ 27 | ; keyboard constants 28 | ;============================================================ 29 | 30 | Const_KBD_BUFFER = $c5 ; 31 | Const_UP = $09 ; 32 | Const_DOWN = $0c ;values 33 | Const_LEFT = $0a ;for up down left right 34 | Const_RIGHT = $0d ; 35 | Const_QKEY = $3e 36 | Const_NOKEY = $40 37 | 38 | ;============================================================ 39 | ; This is done to avoid multiplication through looped addition-->performance 40 | ; If each map row was 20 wide then: 41 | ; 20, 40, 60, 80 etc... until bottom of mapped data 42 | Const_GMAP_L byte GAMEMAP0,>GAMEMAP1,>GAMEMAP2,>GAMEMAP3,>GAMEMAP4,>GAMEMAP5,>GAMEMAP6,>GAMEMAP7,>GAMEMAP8,>GAMEMAP9 44 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 45 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 46 | ;============================================================ 47 | ; ******* G A M E M A P ******* 48 | ;============================================================ 49 | 50 | GAMEMAP0 text '-----gray defender--xxxxxxxxxxxxx xxxxxo' 51 | GAMEMAP1 text '-------owooot ------xxxxxxxxxxxxx xxxxxo' 52 | GAMEMAP2 text '-----o------oo------xxxxvvvvxxx xxo' 53 | GAMEMAP3 text '----o---------o-----xxxxxxvvvxxxxxxx xxo' 54 | GAMEMAP4 text '---o-o---------oo---xxxxxxxxxxx xxo' 55 | GAMEMAP5 text '----o---HI-----o----aaabbbcccdd eeefffgo' 56 | GAMEMAP6 text '-----o--------o-----01234g12345 1234o' 57 | GAMEMAP7 text '------o------o------jjjjjjkkkkkll mmmmmo' 58 | GAMEMAP8 text '-------o-oooo-------nnnnnnooooopp qqqqqo' 59 | GAMEMAP9 text '--------------------rrrrrrssssstt uuuvvo' 60 | ;============================================================ 61 | ; Program Macros 62 | ;============================================================ 63 | 64 | defm store_values_y ; This macro loads first 65 | lda /1,y ; param then stores in 66 | sta /2 ; second param 67 | lda /3,y ; the loads third and 68 | sta /4 ; stores in forth 69 | endm 70 | 71 | ;============================================================ 72 | ; Check NX or NY (Internal view port x,y) against viewport width,height 73 | ; Reset the value back down (wrap around) by subtracting difference 74 | ; IE if nx>20 then nx=nx-20 75 | ; IE if ny>10 then ny=ny-10 76 | ; This is the code that causes the map to wrap around when 77 | ; moving all the way right or all the way down past the borders 78 | ;============================================================ 79 | defm Check_NXNY 80 | clc 81 | adc /1 82 | sta /2 83 | clc 84 | cmp /3 85 | beq @reset 86 | bcc @bot 87 | @reset sbc /3 88 | sta /2 89 | @bot 90 | endm 91 | 92 | ;============================================================ 93 | ; load param 1 test against param 2 if match reset to param 3 -1 94 | ; storing result in param 1 95 | ; This code keeps the map within the proper boundaries as 96 | ; defined by the map height and map width 97 | ;============================================================ 98 | defm Range_Test 99 | lda /1 100 | clc 101 | cmp /2 102 | bne @bottom 103 | lda /3 104 | sbc #1 105 | sta /1 106 | @bottom 107 | endm 108 | 109 | defm Check_Wrap 110 | clc 111 | adc /1 112 | cmp /2 113 | bcc @skip 114 | sbc /2 115 | @skip 116 | tay 117 | endm 118 | 119 | ;============================================================ 120 | ; PROGRAM START (Grab Keyboard Input) 121 | ;============================================================ 122 | *=$1000 123 | lda #$93 ; shift clear dec 147 124 | jsr $FFD2 ; clear screen 125 | main_loop jsr move_routine 126 | jsr delay 127 | 128 | @nokey lda Const_KBD_BUFFER ; Input a key from the keyboard 129 | cmp #Const_NOKEY ; Nothing being pressed 130 | beq @nokey 131 | cmp #Const_Qkey ; q key pressed ? 132 | beq quit_prg 133 | cmp #Const_LEFT ; a key pressed? move left 134 | beq move_left ; 135 | cmp #Const_RIGHT ; s key pressed? move right 136 | beq move_right ; 137 | cmp #Const_DOWN ; w key pressed? move up 138 | beq move_up ; 139 | cmp #Const_UP ; z key pressed? move up 140 | bne main_loop ; 141 | move_down inc vy ; Move map down vy=vy+1 142 | Range_Test vy,#Const_gmap_height,#1 ;Test vy for map_height reset to 0 if match 143 | jmp main_loop 144 | move_left dec vx ;Move map left vx=vx-1 145 | Range_Test vx,#$ff,#Const_gmap_width ;Test vx for -1 reset to width if match 146 | jmp main_loop 147 | move_right inc vx ;Move map right vx=vx+1 148 | Range_Test vx,#Const_gmap_width,#1 149 | jmp main_loop 150 | move_up dec vy ;Move map up vy=vy-1 151 | Range_Test vy,#$ff,#Const_gmap_height;Test vy for -1 reset to height if match 152 | jmp main_loop 153 | quit_prg rts 154 | 155 | ;============================================================ 156 | ; MOVEMENT ROUTINE 157 | ; Two loops that draw the map based on the view port vars 158 | ;============================================================ 159 | 160 | move_routine ldy #0 161 | loop_vert store_values_y Const_Screen_L,output+1,Const_Screen_H,output+2 162 | tya 163 | sta tempy+1 164 | Check_Wrap vy,#Const_gmap_height 165 | store_values_y Const_GMAP_L,input+1,Const_GMAP_H,input+2 166 | ldx #0 167 | loop_horiz txa 168 | Check_Wrap vx,#Const_gmap_width 169 | input lda gamemap0,y 170 | output sta $400,x 171 | inx 172 | loop_cpx cpx Const_SCN_View_WD 173 | bne loop_horiz 174 | tempy ldy #$00 175 | iny 176 | cpy #Const_SCN_View_HT 177 | bne loop_vert 178 | rts 179 | ;========================================================== 180 | ; END PROGRAM 181 | ;========================================================== 182 | delay ldy #50 183 | @loop2 ldx #0 184 | @loop dex 185 | bne @loop 186 | dey 187 | bne @loop2 188 | rts 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /bak/zef2.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; Revised 4 | ; 4/20/2017 5 | ; Rewrote part of the program that displays data on the screen 6 | ; tried to make it more efficient 7 | ; Changed input routine to read kbd from $c5 8 | ;============================================================ 9 | ; Quick code to create auto execute program from basic 10 | ;============================================================ 11 | 12 | *=$0801 13 | byte $0c, $08, $0a, $00, $9e, $20 14 | byte $34, $30, $39, $36, $00, $00 15 | byte $00 16 | ;============================================================ 17 | ; Adjustable Variables and constants 18 | ;============================================================ 19 | Const_SCREEN_WD = #40 ;text width of screen (c64) 20 | Const_SCN_View_WD = #15 ;width of view port (viewable on screen) 21 | Const_SCN_View_HT = #10 ;height of view port (viewable on screen) 22 | Const_gmap_width = 40 ;Width of game map data 23 | Const_gmap_height = 10 ;Height of game map data 24 | vx byte 5 ;Starting x position into the game map data 25 | vy byte 5 ;Starting y position into the game map data 26 | ;============================================================ 27 | ; keyboard constants 28 | ;============================================================ 29 | 30 | Const_KBD_BUFFER = $c5 ; 31 | Const_UP = $09 ; 32 | Const_DOWN = $0c ;values 33 | Const_LEFT = $0a ;for up down left right 34 | Const_RIGHT = $0d ; 35 | Const_QKEY = $3e 36 | Const_NOKEY = $40 37 | 38 | ;============================================================ 39 | ; This is done to avoid multiplication through looped addition-->performance 40 | ; If each map row was 20 wide then: 41 | ; 20, 40, 60, 80 etc... until bottom of mapped data 42 | Const_GMAP_L byte GAMEMAP0,>GAMEMAP1,>GAMEMAP2,>GAMEMAP3,>GAMEMAP4,>GAMEMAP5,>GAMEMAP6,>GAMEMAP7,>GAMEMAP8,>GAMEMAP9 44 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 45 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 46 | ;============================================================ 47 | ; ******* G A M E M A P ******* 48 | ;============================================================ 49 | 50 | GAMEMAP0 text '-----gray defender--xxxxxxxxxxxxx xxxxxo' 51 | GAMEMAP1 text '-------owooot ------xxxxxxxxxxxxx xxxxxo' 52 | GAMEMAP2 text '-----o------oo------xxxxvvvvxxx xxo' 53 | GAMEMAP3 text '----o---------o-----xxxxxxvvvxxxxxxx xxo' 54 | GAMEMAP4 text '---o-o---------oo---xxxxxxxxxxx xxo' 55 | GAMEMAP5 text '----o---HI-----o----aaabbbcccdd eeefffgo' 56 | GAMEMAP6 text '-----o--------o-----01234g12345 1234o' 57 | GAMEMAP7 text '------o------o------jjjjjjkkkkkll mmmmmo' 58 | GAMEMAP8 text '-------o-oooo-------nnnnnnooooopp qqqqqo' 59 | GAMEMAP9 text '--------------------rrrrrrssssstt uuuvvo' 60 | ;============================================================ 61 | ; Program Macros 62 | ;============================================================ 63 | 64 | defm store_values_y ; This macro loads first 65 | lda /1,y ; param then stores in 66 | sta /2 ; second param 67 | lda /3,y ; the loads third and 68 | sta /4 ; stores in forth 69 | endm 70 | 71 | ;============================================================ 72 | ; Check NX or NY (Internal view port x,y) against viewport width,height 73 | ; Reset the value back down (wrap around) by subtracting difference 74 | ; IE if nx>20 then nx=nx-20 75 | ; IE if ny>10 then ny=ny-10 76 | ; This is the code that causes the map to wrap around when 77 | ; moving all the way right or all the way down past the borders 78 | ;============================================================ 79 | defm Check_NXNY 80 | clc 81 | adc /1 82 | sta /2 83 | clc 84 | cmp /3 85 | beq @reset 86 | bcc @bot 87 | @reset sbc /3 88 | sta /2 89 | @bot 90 | endm 91 | 92 | ;============================================================ 93 | ; load param 1 test against param 2 if match reset to param 3 -1 94 | ; storing result in param 1 95 | ; This code keeps the map within the proper boundaries as 96 | ; defined by the map height and map width 97 | ;============================================================ 98 | defm Range_Test 99 | lda /1 100 | clc 101 | cmp /2 102 | bne @bottom 103 | lda /3 104 | sbc #1 105 | sta /1 106 | @bottom 107 | endm 108 | 109 | defm Check_Wrap 110 | clc 111 | adc /1 112 | cmp /2 113 | bcc @skip 114 | sbc /2 115 | @skip 116 | tay 117 | endm 118 | 119 | ;============================================================ 120 | ; PROGRAM START (Grab Keyboard Input) 121 | ;============================================================ 122 | *=$1000 123 | lda #$93 ; shift clear dec 147 124 | jsr $FFD2 ; clear screen 125 | main_loop jsr move_routine 126 | jsr delay 127 | 128 | @nokey lda Const_KBD_BUFFER ; Input a key from the keyboard 129 | cmp #Const_NOKEY ; Nothing being pressed 130 | beq @nokey 131 | cmp #Const_Qkey ; q key pressed ? 132 | beq quit_prg 133 | cmp #Const_LEFT ; a key pressed? move left 134 | beq move_left ; 135 | cmp #Const_RIGHT ; s key pressed? move right 136 | beq move_right ; 137 | cmp #Const_DOWN ; w key pressed? move up 138 | beq move_up ; 139 | cmp #Const_UP ; z key pressed? move up 140 | bne main_loop ; 141 | move_down inc vy ; Move map down vy=vy+1 142 | Range_Test vy,#Const_gmap_height,#1 ;Test vy for map_height reset to 0 if match 143 | jmp main_loop 144 | move_left dec vx ;Move map left vx=vx-1 145 | Range_Test vx,#$ff,#Const_gmap_width ;Test vx for -1 reset to width if match 146 | jmp main_loop 147 | move_right inc vx ;Move map right vx=vx+1 148 | Range_Test vx,#Const_gmap_width,#1 149 | jmp main_loop 150 | move_up dec vy ;Move map up vy=vy-1 151 | Range_Test vy,#$ff,#Const_gmap_height;Test vy for -1 reset to height if match 152 | jmp main_loop 153 | quit_prg rts 154 | 155 | ;============================================================ 156 | ; MOVEMENT ROUTINE 157 | ; Two loops that draw the map based on the view port vars 158 | ;============================================================ 159 | 160 | move_routine ldy #0 161 | loop_vert store_values_y Const_Screen_L,output+1,Const_Screen_H,output+2 162 | tya 163 | sta tempy+1 164 | Check_Wrap vy,#Const_gmap_height 165 | store_values_y Const_GMAP_L,input+1,Const_GMAP_H,input+2 166 | ldx #0 167 | loop_horiz txa 168 | Check_Wrap vx,#Const_gmap_width 169 | input lda gamemap0,y 170 | output sta $400,x 171 | inx 172 | loop_cpx cpx Const_SCN_View_WD 173 | bne loop_horiz 174 | tempy ldy #$00 175 | iny 176 | cpy #Const_SCN_View_HT 177 | bne loop_vert 178 | rts 179 | ;========================================================== 180 | ; END PROGRAM 181 | ;========================================================== 182 | delay ldy #50 183 | @loop2 ldx #0 184 | @loop dex 185 | bne @loop 186 | dey 187 | bne @loop2 188 | rts 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /box.asm: -------------------------------------------------------------------------------- 1 | 2 | *=$1000 3 | 4 | 5 | lda #$93 ; shift clear dec 147 6 | jsr $FFD2 ; clear screen 7 | start_over jsr Init_Random 8 | 9 | GET_RAND #37,Const_BOX_X,#41,width 10 | GET_RAND #21,Const_BOX_Y,#26,height 11 | lda #15 12 | sta RAND_MAX 13 | jsr RAND 14 | sta Const_Box_Color 15 | ; jsr draw_box 16 | ; jmp start_over 17 | 18 | ; rts 19 | 20 | @loop2 jsr Box_Effect 21 | jmp @loop2 22 | rts 23 | 24 | draw_box 25 | ldy Const_BOX_Y 26 | lda Const_Screen_L,y 27 | sta left_top_edge+1 28 | sta left_top_edgec+1 29 | lda Const_Screen_H,y 30 | sta left_top_edge+2 31 | lda Const_Screen_C,y 32 | sta left_top_edgec+2 33 | clc 34 | dey 35 | tya 36 | adc height 37 | tay 38 | lda Const_Screen_L,y 39 | sta left_bot_edge+1 40 | sta left_bot_edgec+1 41 | lda Const_Screen_H,y 42 | sta left_bot_edge+2 43 | lda Const_Screen_C,y 44 | sta left_bot_edgec+2 45 | ldx Const_BOX_X 46 | ldy #0 47 | lda #$2 48 | left_top_edge sta $400,x 49 | left_bot_edge sta $450,x 50 | lda Const_Box_Color 51 | left_top_edgec sta $d800,x 52 | left_bot_edgec sta $d800,x 53 | 54 | inx 55 | iny 56 | box_width cpy width 57 | bne left_top_edge-2 58 | ldx #2 ; Accounts for top and bottom of box => just draw middle 59 | ldy Const_BOX_Y 60 | iny 61 | loop2 lda Const_Screen_L,y 62 | sta box_top_left+1 63 | sta box_top_right+1 64 | sta box_top_leftc+1 65 | sta box_top_rightc+1 66 | lda Const_Screen_H,y 67 | sta box_top_left+2 68 | sta box_top_right+2 69 | lda Const_Screen_C,y 70 | sta box_top_leftc+2 71 | sta box_top_rightc+2 72 | 73 | txa 74 | pha 75 | ldx Const_Box_X 76 | lda #$1 77 | box_top_left sta $400,x 78 | lda Const_Box_Color 79 | box_top_leftc sta $d800,x 80 | 81 | dex 82 | txa 83 | clc 84 | adc width 85 | tax 86 | lda #1 87 | box_top_right sta $400,x 88 | lda Const_Box_Color 89 | box_top_rightc sta $d800,x 90 | pla 91 | tax 92 | inx 93 | iny 94 | cpx height 95 | bne loop2 96 | rts 97 | 98 | 99 | defm GET_RAND 100 | 101 | @do_over lda /1 ; Get RAND Start Pos 102 | sta RAND_MAX 103 | jsr RAND ; Get random between 0 and 37 104 | sta /2 105 | lda /3 ; Get rand WIDTH 106 | sta RAND_MAX 107 | @larger jsr RAND 108 | cmp #3 109 | bcc @larger 110 | sta /4 111 | 112 | clc 113 | adc /2 114 | cmp /3 115 | bcs @do_over 116 | endm 117 | 118 | 119 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 120 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 121 | Const_Screen_C byte $d8,$d8,$d8,$d8,$d8,$d8,$d8,$d9,$d9,$d9,$d9,$d9,$d9,$da,$da,$da,$da,$da,$da,$da,$db,$db,$db,$db,$db 122 | RAND_MAX byte 00 123 | height byte 25 124 | width byte 40 125 | Const_BOX_X byte 0 126 | Const_Box_Y byte 0 127 | Const_Box_Color byte 2 128 | 129 | 130 | ;============================================================ 131 | Init_Random 132 | LDA #$FF ; maximum frequency value 133 | STA $D40E ; voice 3 frequency low byte 134 | STA $D40F ; voice 3 frequency high byte 135 | LDA #$80 ; noise SIRENform, gate bit off 136 | STA $D412 ; voice 3 control register 137 | rts 138 | 139 | RAND 140 | LDA $D41B ; get random value from 0-255 141 | CMP RAND_MAX ; narrow random result down 142 | ; to between zero - g$len 143 | BCC @dont_crash ; ~ to 0-3 144 | jmp RAND 145 | @dont_crash rts 146 | 147 | delay ldy #5 148 | @loop2 ldx #0 149 | @loop dex 150 | bne @loop 151 | dey 152 | bne @loop2 153 | rts 154 | 155 | Box_Effect 156 | lda #0 157 | sta Const_Box_X 158 | sta Const_Box_Y 159 | lda #40 160 | sta width 161 | lda #25 162 | sta height 163 | 164 | ldx #0 165 | @loop txa 166 | pha 167 | jsr draw_box 168 | jsr delay 169 | pla 170 | tax 171 | inc Const_Box_X 172 | inc Const_Box_Y 173 | dec width 174 | dec width 175 | dec height 176 | dec height 177 | inc Const_Box_Color 178 | inx 179 | cpx #12 180 | bne @loop 181 | rts 182 | Box_Effect2 183 | lda #0 184 | sta Const_Box_X 185 | sta Const_Box_Y 186 | lda #40 187 | sta width 188 | lda #25 189 | sta height 190 | 191 | ldx #0 192 | @loop txa 193 | pha 194 | lda #2 195 | sta Const_Box_Color 196 | 197 | jsr draw_box 198 | jsr delay 199 | lda #3 200 | sta Const_Box_Color 201 | jsr draw_box 202 | 203 | pla 204 | tax 205 | inc Const_Box_X 206 | inc Const_Box_Y 207 | dec width 208 | dec width 209 | dec height 210 | dec height 211 | 212 | inx 213 | cpx #12 214 | bne @loop 215 | 216 | ldx #12 217 | jmp @intoit 218 | @loop2 txa 219 | pha 220 | lda #2 221 | sta Const_Box_Color 222 | 223 | jsr draw_box 224 | jsr delay 225 | lda #3 226 | sta Const_Box_Color 227 | jsr draw_box 228 | 229 | pla 230 | tax 231 | @intoit dec Const_Box_X 232 | dec Const_Box_Y 233 | inc width 234 | inc width 235 | inc height 236 | inc height 237 | 238 | dex 239 | cpx #0 240 | bne @loop2 241 | rts 242 | 243 | -------------------------------------------------------------------------------- /zef1.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; 4 | ;============================================================ 5 | ; Quick code to create auto execute program from basic 6 | ;============================================================ 7 | 8 | *=$0801 9 | byte $0c, $08, $0a, $00, $9e, $20 10 | byte $34, $30, $39, $36, $00, $00 11 | byte $00 12 | ;============================================================ 13 | scn_width$ = #40 ;text width of screen (c64) 14 | view_wd$ = #8 ;width of view port (viewable on screen) 15 | view_ht$ = #8 ;height of view port (viewable on screen) 16 | 17 | 18 | ;============================================================ 19 | ; Main Program Variables 20 | ;============================================================ 21 | scn_offset word $0004 ;c64 screen offset 22 | map_offset word $0000 ;Offset into the Map data 23 | cx byte 0 ;Starting x position into the map BYTE 60,126,126,126,126,126,60,0 24 | BYTE 216,132,196,100,20,24,0,0 25 | 26 | cy byte 0 ;Starting y position into the map 27 | nx byte 0 ;Horizontal variable that wraps around 28 | ny byte 0 ;Vertical variable that wraps around 29 | tempy byte 0 ;Temp storage for Y Register 30 | map_width byte 20 ;Width of map data 31 | map_height byte 10 ;Height of map data 32 | 33 | astring text '-----gray defender--' 34 | text '-------owooot ------' 35 | text '-----o------oo------' 36 | text '----o---------o-----' 37 | text '---o-o---------oo---' 38 | text '----o---HI-----o----' 39 | text '-----o--------o-----' 40 | text '------o------o------' 41 | text '-------o-oooo-------' 42 | text '--------------------' 43 | 44 | ;============================================================ 45 | ; This is done to avoid multiplication through looped addition-->performance 46 | ; So, 20, 40, 60, 80 etc... until bottom of mapped data 47 | map_off byte $00,$14,$28,$3c,$50,$64,$78,$8c,$a0,$b4 ;vertical scn_offset into map data 48 | ;============================================================ 49 | 50 | defm mydec ; Quick macros to clean up input code from keyboard 51 | dec /1 ; 52 | jmp main_loop ; 53 | endm 54 | defm myinc 55 | inc /1 56 | jmp main_loop 57 | endm 58 | 59 | defm add_scn_offset ; Add a number to a memory location 60 | clc ; Increment hi byte if carry 61 | lda /1 62 | adc /2 63 | sta /1 64 | bcc @ok 65 | inc /1+1 66 | @ok 67 | endm 68 | 69 | defm set_indirect ; store values in $FB, $FC 70 | lda /1 ; for address indirection 71 | sta $fb ; usage 72 | lda /2 73 | sta $fc 74 | endm 75 | 76 | ;============================================================ 77 | ; Check NX or NY (Internal view port x,y) against viewport width,height 78 | ; Reset the value back down (wrap around) by subtracting difference 79 | ; IE if nx>20 then nx=nx-20 80 | ; IE if ny>10 then ny=ny-10 81 | ; This is the code that causes the map to wrap around when 82 | ; moving all the way right or all the way down past the borders 83 | ;============================================================ 84 | defm Check_NXNY 85 | clc 86 | adc /1 87 | sta /2 88 | clc 89 | cmp /3 90 | beq @reset 91 | bcc @bot 92 | @reset sbc /3 93 | sta /2 94 | @bot 95 | endm 96 | 97 | ;============================================================ 98 | ; load param 1 test against param 2 if match reset to param 3 99 | ; This code keeps the map within the proper boundaries as 100 | ; defined by the map height and map width 101 | ;============================================================ 102 | defm Range_Test 103 | lda /1 104 | clc 105 | cmp /2 106 | bne @bottom 107 | lda /3 108 | sbc #1 109 | sta /1 110 | @bottom 111 | endm 112 | ;============================================================ 113 | ; PROGRAM START (Grab Keyboard Input) 114 | ;============================================================ 115 | *=$1000 116 | lda #$93 ; shift clear dec 147 117 | JSR $FFD2 ; clear screen 118 | main_loop 119 | jsr move_routine 120 | jsr $ffe4 ; Input a key from the keyboard 121 | cmp #$51 ; q key pressed ? 122 | beq quit_prg 123 | cmp #$41 ; a key pressed? move left 124 | beq move_left ; 125 | cmp #$53 ; s key pressed? move right 126 | beq move_right ; 127 | cmp #$57 ; w key pressed? move up 128 | beq move_up ; 129 | cmp #$5a ; z key pressed? move up 130 | beq move_down ; 131 | jmp main_loop 132 | 133 | move_left mydec cx ;Move map left cx=cx-1 134 | move_right myinc cx ;Move map right cx=cx+1 135 | move_up mydec cy ;Move map up cy=cy-1 136 | move_down myinc cy ;Move map down cy=cy+1 137 | 138 | quit_prg rts 139 | 140 | ;============================================================ 141 | ; MOVEMENT ROUTINE 142 | ; This section checks the cx and cy variables to make 143 | ; sure the map displayed on the screen stays within the 144 | ; boundaries of the those variables 145 | ;============================================================ 146 | 147 | move_routine Range_Test cy,#$ff,map_height ; Test cy for -1 reset to height if match 148 | Range_Test cy,map_height,#1 ; Test cy for map_height reset to 0 if match 149 | Range_Test cx,#$ff,map_width ; Test cx for -1 reset to width if match 150 | Range_Test cx,map_width,#1 ; Test cx for map width reset to 0 if match 151 | 152 | 153 | lda #$e0 ;Set Inital Map screen scn_offset 154 | sta scn_offset ;Inital location of top left 155 | lda #$04 ;view port on the screen 156 | sta scn_offset+1 157 | lda #$00 158 | sta map_offset 159 | sta map_offset+1 160 | ;========================================================== 161 | ; Beginning Loop (vertical section) 162 | ;========================================================== 163 | ldx #$0 ; Outer loop 164 | lp_x txa 165 | Check_NXNY cy,ny,map_height ; Reset NY if wrap at bottom of map 166 | jsr calc_offset ; calc map offset=ny*map width 167 | ;========================================================== 168 | ; Beginning Loop (horizontal section) 169 | ;========================================================== 170 | ldy #$0 ; Inner Loop 171 | loop_y tya 172 | Check_NXNY cx,nx,map_width ;Reset NX if wrap at right side of map 173 | 174 | sty tempy ;Store Y register 175 | 176 | set_indirect #astring ;Load up $fb, $fc to do an indirect lookup of astring 177 | lda map_offset 178 | clc 179 | adc nx 180 | tay 181 | lda ($fb),y 182 | pha ;Store A which is the Current Char in map 183 | ldy tempy ;Restore Y Register 184 | 185 | set_indirect scn_offset,scn_offset+1; Load up $fb, $fc to do an indirect lookup of scn_offset 186 | 187 | pla ; Restore A, which is map character 188 | sta ($fb),y ; Display map character on the screen 189 | iny ; increment y register, which is used here for horizontal 190 | cpy view_wd$ ; check if at end if current line width 191 | bne loop_y ; Nope? back to top of loop 192 | 193 | add_scn_offset scn_offset,scn_width$;Jump the screen pointer down 194 | add_scn_offset map_offset,map_width ;IE scn_offset=scn_offset+40, map_offset=map_offset+20 195 | 196 | ;========================================================== 197 | inx ; increment x register, which is used here for vertical 198 | cpx view_ht$ ; check if at the bottom row of the map height 199 | bne duck ; Nope? back to top of loop 200 | rts 201 | duck jmp lp_x 202 | rts 203 | 204 | ;========================================================== 205 | ; END PROGRAM 206 | ;========================================================== 207 | 208 | ;========================================================== 209 | ; This sub uses a table of pre-calculated starting positions 210 | ; for each y row of the map, eliminating the need for doing 211 | ; expensive math calculations (adds or mults) 212 | ;========================================================== 213 | 214 | calc_offset txa ; Save off the X register 215 | pha ; Push to stack 216 | ldx ny 217 | lda map_off,x 218 | sta map_offset 219 | pla ; Pull from stack 220 | tax ; Restore the X register 221 | rts 222 | 223 | ;slow_down ldx delay 224 | ; inx 225 | ; stx delay 226 | ; bne slow_down 227 | ; rts 228 | -------------------------------------------------------------------------------- /bak/zef1.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; 4 | ;============================================================ 5 | ; Quick code to create auto execute program from basic 6 | ;============================================================ 7 | 8 | *=$0801 9 | byte $0c, $08, $0a, $00, $9e, $20 10 | byte $34, $30, $39, $36, $00, $00 11 | byte $00 12 | ;============================================================ 13 | scn_width$ = #40 ;text width of screen (c64) 14 | view_wd$ = #8 ;width of view port (viewable on screen) 15 | view_ht$ = #8 ;height of view port (viewable on screen) 16 | 17 | 18 | ;============================================================ 19 | ; Main Program Variables 20 | ;============================================================ 21 | scn_offset word $0004 ;c64 screen offset 22 | map_offset word $0000 ;Offset into the Map data 23 | cx byte 0 ;Starting x position into the map BYTE 60,126,126,126,126,126,60,0 24 | BYTE 216,132,196,100,20,24,0,0 25 | 26 | cy byte 0 ;Starting y position into the map 27 | nx byte 0 ;Horizontal variable that wraps around 28 | ny byte 0 ;Vertical variable that wraps around 29 | tempy byte 0 ;Temp storage for Y Register 30 | map_width byte 20 ;Width of map data 31 | map_height byte 10 ;Height of map data 32 | 33 | astring text '-----gray defender--' 34 | text '-------owooot ------' 35 | text '-----o------oo------' 36 | text '----o---------o-----' 37 | text '---o-o---------oo---' 38 | text '----o---HI-----o----' 39 | text '-----o--------o-----' 40 | text '------o------o------' 41 | text '-------o-oooo-------' 42 | text '--------------------' 43 | 44 | ;============================================================ 45 | ; This is done to avoid multiplication through looped addition-->performance 46 | ; So, 20, 40, 60, 80 etc... until bottom of mapped data 47 | map_off byte $00,$14,$28,$3c,$50,$64,$78,$8c,$a0,$b4 ;vertical scn_offset into map data 48 | ;============================================================ 49 | 50 | defm mydec ; Quick macros to clean up input code from keyboard 51 | dec /1 ; 52 | jmp main_loop ; 53 | endm 54 | defm myinc 55 | inc /1 56 | jmp main_loop 57 | endm 58 | 59 | defm add_scn_offset ; Add a number to a memory location 60 | clc ; Increment hi byte if carry 61 | lda /1 62 | adc /2 63 | sta /1 64 | bcc @ok 65 | inc /1+1 66 | @ok 67 | endm 68 | 69 | defm set_indirect ; store values in $FB, $FC 70 | lda /1 ; for address indirection 71 | sta $fb ; usage 72 | lda /2 73 | sta $fc 74 | endm 75 | 76 | ;============================================================ 77 | ; Check NX or NY (Internal view port x,y) against viewport width,height 78 | ; Reset the value back down (wrap around) by subtracting difference 79 | ; IE if nx>20 then nx=nx-20 80 | ; IE if ny>10 then ny=ny-10 81 | ; This is the code that causes the map to wrap around when 82 | ; moving all the way right or all the way down past the borders 83 | ;============================================================ 84 | defm Check_NXNY 85 | clc 86 | adc /1 87 | sta /2 88 | clc 89 | cmp /3 90 | beq @reset 91 | bcc @bot 92 | @reset sbc /3 93 | sta /2 94 | @bot 95 | endm 96 | 97 | ;============================================================ 98 | ; load param 1 test against param 2 if match reset to param 3 99 | ; This code keeps the map within the proper boundaries as 100 | ; defined by the map height and map width 101 | ;============================================================ 102 | defm Range_Test 103 | lda /1 104 | clc 105 | cmp /2 106 | bne @bottom 107 | lda /3 108 | sbc #1 109 | sta /1 110 | @bottom 111 | endm 112 | ;============================================================ 113 | ; PROGRAM START (Grab Keyboard Input) 114 | ;============================================================ 115 | *=$1000 116 | lda #$93 ; shift clear dec 147 117 | JSR $FFD2 ; clear screen 118 | main_loop 119 | jsr move_routine 120 | jsr $ffe4 ; Input a key from the keyboard 121 | cmp #$51 ; q key pressed ? 122 | beq quit_prg 123 | cmp #$41 ; a key pressed? move left 124 | beq move_left ; 125 | cmp #$53 ; s key pressed? move right 126 | beq move_right ; 127 | cmp #$57 ; w key pressed? move up 128 | beq move_up ; 129 | cmp #$5a ; z key pressed? move up 130 | beq move_down ; 131 | jmp main_loop 132 | 133 | move_left mydec cx ;Move map left cx=cx-1 134 | move_right myinc cx ;Move map right cx=cx+1 135 | move_up mydec cy ;Move map up cy=cy-1 136 | move_down myinc cy ;Move map down cy=cy+1 137 | 138 | quit_prg rts 139 | 140 | ;============================================================ 141 | ; MOVEMENT ROUTINE 142 | ; This section checks the cx and cy variables to make 143 | ; sure the map displayed on the screen stays within the 144 | ; boundaries of the those variables 145 | ;============================================================ 146 | 147 | move_routine Range_Test cy,#$ff,map_height ; Test cy for -1 reset to height if match 148 | Range_Test cy,map_height,#1 ; Test cy for map_height reset to 0 if match 149 | Range_Test cx,#$ff,map_width ; Test cx for -1 reset to width if match 150 | Range_Test cx,map_width,#1 ; Test cx for map width reset to 0 if match 151 | 152 | 153 | lda #$e0 ;Set Inital Map screen scn_offset 154 | sta scn_offset ;Inital location of top left 155 | lda #$04 ;view port on the screen 156 | sta scn_offset+1 157 | lda #$00 158 | sta map_offset 159 | sta map_offset+1 160 | ;========================================================== 161 | ; Beginning Loop (vertical section) 162 | ;========================================================== 163 | ldx #$0 ; Outer loop 164 | lp_x txa 165 | Check_NXNY cy,ny,map_height ; Reset NY if wrap at bottom of map 166 | jsr calc_offset ; calc map offset=ny*map width 167 | ;========================================================== 168 | ; Beginning Loop (horizontal section) 169 | ;========================================================== 170 | ldy #$0 ; Inner Loop 171 | loop_y tya 172 | Check_NXNY cx,nx,map_width ;Reset NX if wrap at right side of map 173 | 174 | sty tempy ;Store Y register 175 | 176 | set_indirect #astring ;Load up $fb, $fc to do an indirect lookup of astring 177 | lda map_offset 178 | clc 179 | adc nx 180 | tay 181 | lda ($fb),y 182 | pha ;Store A which is the Current Char in map 183 | ldy tempy ;Restore Y Register 184 | 185 | set_indirect scn_offset,scn_offset+1; Load up $fb, $fc to do an indirect lookup of scn_offset 186 | 187 | pla ; Restore A, which is map character 188 | sta ($fb),y ; Display map character on the screen 189 | iny ; increment y register, which is used here for horizontal 190 | cpy view_wd$ ; check if at end if current line width 191 | bne loop_y ; Nope? back to top of loop 192 | 193 | add_scn_offset scn_offset,scn_width$;Jump the screen pointer down 194 | add_scn_offset map_offset,map_width ;IE scn_offset=scn_offset+40, map_offset=map_offset+20 195 | 196 | ;========================================================== 197 | inx ; increment x register, which is used here for vertical 198 | cpx view_ht$ ; check if at the bottom row of the map height 199 | bne duck ; Nope? back to top of loop 200 | rts 201 | duck jmp lp_x 202 | rts 203 | 204 | ;========================================================== 205 | ; END PROGRAM 206 | ;========================================================== 207 | 208 | ;========================================================== 209 | ; This sub uses a table of pre-calculated starting positions 210 | ; for each y row of the map, eliminating the need for doing 211 | ; expensive math calculations (adds or mults) 212 | ;========================================================== 213 | 214 | calc_offset txa ; Save off the X register 215 | pha ; Push to stack 216 | ldx ny 217 | lda map_off,x 218 | sta map_offset 219 | pla ; Pull from stack 220 | tax ; Restore the X register 221 | rts 222 | 223 | ;slow_down ldx delay 224 | ; inx 225 | ; stx delay 226 | ; bne slow_down 227 | ; rts 228 | -------------------------------------------------------------------------------- /zef3.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; Revised 4 | ; 4/20/2017 5 | ; Rewrote part of the program that displays data on the screen 6 | ; tried to make it more efficient 7 | ; Changed input routine to read kbd from $c5 8 | ; 5/6/2017 9 | ; Added shifting water effect with program interrupt and 10 | ; redefined character set 11 | ;============================================================ 12 | ; Quick code to create auto execute program from basic 13 | ;============================================================ 14 | 15 | *=$0801 16 | byte $0c, $08, $0a, $00, $9e, $20 17 | byte $34, $30, $39, $36, $00, $00 18 | byte $00 19 | ;============================================================ 20 | ; Adjustable Variables and constants 21 | ;============================================================ 22 | Const_SCREEN_WD = #40 ;text width of screen (c64) 23 | Const_SCN_View_WD = #15 ;width of view port (viewable on screen) 24 | Const_SCN_View_HT = #10 ;height of view port (viewable on screen) 25 | Const_gmap_width = 40 ;Width of game map data 26 | Const_gmap_height = 10 ;Height of game map data 27 | vx byte 5 ;Starting x position into the game map data 28 | vy byte 5 ;Starting y position into the game map data 29 | ;============================================================ 30 | ; keyboard constants 31 | ;============================================================ 32 | 33 | Const_KBD_BUFFER = $c5 ; 34 | Const_UP = $09 ; 35 | Const_DOWN = $0c ;values 36 | Const_LEFT = $0a ;for up down left right 37 | Const_RIGHT = $0d ; 38 | Const_QKEY = $3e 39 | Const_NOKEY = $40 40 | 41 | ;============================================================ 42 | ; This is done to avoid multiplication through looped addition-->performance 43 | ; If each map row was 20 wide then: 44 | ; 20, 40, 60, 80 etc... until bottom of mapped data 45 | Const_GMAP_L byte GAMEMAP0,>GAMEMAP1,>GAMEMAP2,>GAMEMAP3,>GAMEMAP4,>GAMEMAP5,>GAMEMAP6,>GAMEMAP7,>GAMEMAP8,>GAMEMAP9 47 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 48 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 49 | ;============================================================ 50 | ; ******* G A M E M A P ******* 51 | ;============================================================ 52 | 53 | GAMEMAP0 text '@@@@@gray defender@@xxxxxxxxxxxxx xxxxxo' 54 | GAMEMAP1 text '@@@@@@@owooot @@@@@@xxxxxxxxxxxxx xxxxxo' 55 | GAMEMAP2 text '@@@@@o@@@@@@oo@@@@@@xxxxvvvvxxx xxo' 56 | GAMEMAP3 text '@@@@o@@@@@@@@@o@@@@@xxxxxxvvvxxxxxxx xxo' 57 | GAMEMAP4 text '@@@o@o@@@@@@@@@oo@@@xxxxxxxxxxx xxo' 58 | GAMEMAP5 text '@@@@o@@@HI@@@@@o@@@@aaabbbcccdd eeefffgo' 59 | GAMEMAP6 text '@@@@@o@@@@@@@@o@@@@@01234g12345 1234o' 60 | GAMEMAP7 text '@@@@@@o@@@@@@o@@@@@@jjjjjjkkkkkll mmmmmo' 61 | GAMEMAP8 text '@@@@@@@o@oooo@@@@@@@nnnnnnooooopp qqqqqo' 62 | GAMEMAP9 text '@@@@@@@@@@@@@@@@@@@@rrrrrrssssstt uuuvvo' 63 | ;============================================================ 64 | ; Program Macros 65 | ;============================================================ 66 | 67 | defm store_values_y ; This macro loads first 68 | lda /1,y ; param then stores in 69 | sta /2 ; second param 70 | lda /3,y ; the loads third and 71 | sta /4 ; stores in forth 72 | endm 73 | 74 | ;============================================================ 75 | ; Check NX or NY (Internal view port x,y) against viewport width,height 76 | ; Reset the value back down (wrap around) by subtracting difference 77 | ; IE if nx>20 then nx=nx-20 78 | ; IE if ny>10 then ny=ny-10 79 | ; This is the code that causes the map to wrap around when 80 | ; moving all the way right or all the way down past the borders 81 | ;============================================================ 82 | defm Check_NXNY 83 | clc 84 | adc /1 85 | sta /2 86 | clc 87 | cmp /3 88 | beq @reset 89 | bcc @bot 90 | @reset sbc /3 91 | sta /2 92 | @bot 93 | endm 94 | 95 | ;============================================================ 96 | ; load param 1 test against param 2 if match reset to param 3 -1 97 | ; storing result in param 1 98 | ; This code keeps the map within the proper boundaries as 99 | ; defined by the map height and map width 100 | ;============================================================ 101 | defm Range_Test 102 | lda /1 103 | clc 104 | cmp /2 105 | bne @bottom 106 | lda /3 107 | sbc #1 108 | sta /1 109 | @bottom 110 | endm 111 | 112 | defm Check_Wrap 113 | clc 114 | adc /1 115 | cmp /2 116 | bcc @skip 117 | sbc /2 118 | @skip 119 | tay 120 | endm 121 | 122 | ;============================================================ 123 | ; PROGRAM START (Grab Keyboard Input) 124 | ;============================================================ 125 | *=$1000 126 | lda #$93 ; shift clear dec 147 127 | jsr $FFD2 ; clear screen 128 | jsr Character_Set 129 | 130 | main_loop jsr move_routine 131 | jsr delay 132 | 133 | @nokey lda Const_KBD_BUFFER ; Input a key from the keyboard 134 | cmp #Const_NOKEY ; Nothing being pressed 135 | beq @nokey 136 | cmp #Const_Qkey ; q key pressed ? 137 | beq quit_prg 138 | cmp #Const_LEFT ; a key pressed? move left 139 | beq move_left ; 140 | cmp #Const_RIGHT ; s key pressed? move right 141 | beq move_right ; 142 | cmp #Const_DOWN ; w key pressed? move up 143 | beq move_up ; 144 | cmp #Const_UP ; z key pressed? move up 145 | bne main_loop ; 146 | move_down inc vy ; Move map down vy=vy+1 147 | Range_Test vy,#Const_gmap_height,#1 ;Test vy for map_height reset to 0 if match 148 | jmp main_loop 149 | move_left dec vx ;Move map left vx=vx-1 150 | Range_Test vx,#$ff,#Const_gmap_width ;Test vx for -1 reset to width if match 151 | jmp main_loop 152 | move_right inc vx ;Move map right vx=vx+1 153 | Range_Test vx,#Const_gmap_width,#1 154 | jmp main_loop 155 | move_up dec vy ;Move map up vy=vy-1 156 | Range_Test vy,#$ff,#Const_gmap_height;Test vy for -1 reset to height if match 157 | jmp main_loop 158 | quit_prg rts 159 | 160 | ;============================================================ 161 | ; MOVEMENT ROUTINE 162 | ; Two loops that draw the map based on the view port vars 163 | ;============================================================ 164 | 165 | move_routine ldy #0 166 | loop_vert store_values_y Const_Screen_L,output+1,Const_Screen_H,output+2 167 | tya 168 | sta tempy+1 169 | Check_Wrap vy,#Const_gmap_height 170 | store_values_y Const_GMAP_L,input+1,Const_GMAP_H,input+2 171 | ldx #0 172 | loop_horiz txa 173 | Check_Wrap vx,#Const_gmap_width 174 | input lda gamemap0,y 175 | output sta $400,x 176 | inx 177 | loop_cpx cpx Const_SCN_View_WD 178 | bne loop_horiz 179 | tempy ldy #$00 180 | iny 181 | cpy #Const_SCN_View_HT 182 | bne loop_vert 183 | rts 184 | ;========================================================== 185 | ; END PROGRAM 186 | ;========================================================== 187 | delay ldy #50 188 | @loop2 ldx #0 189 | @loop dex 190 | bne @loop 191 | dey 192 | bne @loop2 193 | rts 194 | ;========================================================== 195 | ; Redefine Character Set 196 | ;========================================================== 197 | 198 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 199 | 200 | Character_Set 201 | sei ; disable interrupts while we copy 202 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 203 | lda #$33 ; make the CPU see the Character Generator ROM... 204 | sta $01 ; ...at $D000 by storing %00110011 into location $01 205 | lda #$d0 ; load high byte of $D000 206 | sta $fc ; store it in a free location we use as vector 207 | LDA #$30 ; 208 | STA $fe ; 209 | LDA #0 ; 210 | STA $fd 211 | ldy #$00 ; init counter with 0 212 | sty $fb ; store it as low byte in the $FB/$FC vector 213 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 214 | sta ($fd),y ; write to the RAM under ROM at same position 215 | iny ; do this 255 times... 216 | bne loop ; ..for low byte $00 to $FF 217 | inc $fc ; when we passed $FF increase high byte... 218 | inc $fe 219 | dex ; ... and decrease X by one before restart 220 | bne loop ; We repeat this until X becomes Zero 221 | lda #$37 ; switch in I/O mapped registers again... 222 | sta $01 ; ... with %00110111 so CPU can see them 223 | cli ; turn off interrupt disable flag 224 | LDA #28 225 | ; 226 | STA $d018 ; 227 | 228 | ; *********************************************************************************** 229 | ; 230 | 231 | ldx #0 232 | @loop lda water,x 233 | sta $3000,x 234 | inx 235 | cpx #8 236 | bne @loop 237 | 238 | lda #0 239 | sta $400 240 | 241 | ; 242 | setup = * 243 | sei ; disable interrupts 244 | lda #intcode ; do the same with the high byte 247 | sta 789 248 | cli ; re-enable interrupts 249 | rts ; return to caller 250 | rts ; return from subroutine 251 | intcode = * 252 | inc value 253 | lda value 254 | cmp #$a 255 | bne end 256 | lda #0 257 | sta value 258 | lda $3000 259 | sta temp 260 | lda $3001 261 | sta $3000 262 | lda $3002 263 | sta $3001 264 | lda $3003 265 | sta $3002 266 | lda $3004 267 | sta $3003 268 | lda $3005 269 | sta $3004 270 | lda $3006 271 | sta $3005 272 | lda $3007 273 | sta $3006 274 | lda temp 275 | sta $3007 276 | end jmp $ea31 277 | temp byte 00 278 | value byte 00 279 | 280 | ;water BYTE $88,$77,$00,$00,$22,$DD,$00,$00 281 | water BYTE $88,$77,$00,$00,$22,$dd,$00,$00 282 | 283 | ;water BYTE $C6,$31,$8C,$43,$30,$8C,$63,$18 284 | ;water BYTE $30,$0C,$03,$C0,$30,$0C,$03,$C0 285 | ;water BYTE $7E,$81,$7E,$81,$7E,$81,$7E,$81 286 | ;water BYTE $DC,$23,$DC,$22,$9D,$62,$9C,$23 287 | ;water BYTE $F0,$0F,$F0,$0F,$F0,$0F,$F0,$0F 288 | ;water BYTE $CC,$33,$CC,$33,$CC,$33,$CC,$33 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /bak/zef3.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; Revised 4 | ; 4/20/2017 5 | ; Rewrote part of the program that displays data on the screen 6 | ; tried to make it more efficient 7 | ; Changed input routine to read kbd from $c5 8 | ; 5/6/2017 9 | ; Added shifting water effect with program interrupt and 10 | ; redefined character set 11 | ;============================================================ 12 | ; Quick code to create auto execute program from basic 13 | ;============================================================ 14 | 15 | *=$0801 16 | byte $0c, $08, $0a, $00, $9e, $20 17 | byte $34, $30, $39, $36, $00, $00 18 | byte $00 19 | ;============================================================ 20 | ; Adjustable Variables and constants 21 | ;============================================================ 22 | Const_SCREEN_WD = #40 ;text width of screen (c64) 23 | Const_SCN_View_WD = #15 ;width of view port (viewable on screen) 24 | Const_SCN_View_HT = #10 ;height of view port (viewable on screen) 25 | Const_gmap_width = 40 ;Width of game map data 26 | Const_gmap_height = 10 ;Height of game map data 27 | vx byte 5 ;Starting x position into the game map data 28 | vy byte 5 ;Starting y position into the game map data 29 | ;============================================================ 30 | ; keyboard constants 31 | ;============================================================ 32 | 33 | Const_KBD_BUFFER = $c5 ; 34 | Const_UP = $09 ; 35 | Const_DOWN = $0c ;values 36 | Const_LEFT = $0a ;for up down left right 37 | Const_RIGHT = $0d ; 38 | Const_QKEY = $3e 39 | Const_NOKEY = $40 40 | 41 | ;============================================================ 42 | ; This is done to avoid multiplication through looped addition-->performance 43 | ; If each map row was 20 wide then: 44 | ; 20, 40, 60, 80 etc... until bottom of mapped data 45 | Const_GMAP_L byte GAMEMAP0,>GAMEMAP1,>GAMEMAP2,>GAMEMAP3,>GAMEMAP4,>GAMEMAP5,>GAMEMAP6,>GAMEMAP7,>GAMEMAP8,>GAMEMAP9 47 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 48 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 49 | ;============================================================ 50 | ; ******* G A M E M A P ******* 51 | ;============================================================ 52 | 53 | GAMEMAP0 text '@@@@@gray defender@@xxxxxxxxxxxxx xxxxxo' 54 | GAMEMAP1 text '@@@@@@@owooot @@@@@@xxxxxxxxxxxxx xxxxxo' 55 | GAMEMAP2 text '@@@@@o@@@@@@oo@@@@@@xxxxvvvvxxx xxo' 56 | GAMEMAP3 text '@@@@o@@@@@@@@@o@@@@@xxxxxxvvvxxxxxxx xxo' 57 | GAMEMAP4 text '@@@o@o@@@@@@@@@oo@@@xxxxxxxxxxx xxo' 58 | GAMEMAP5 text '@@@@o@@@HI@@@@@o@@@@aaabbbcccdd eeefffgo' 59 | GAMEMAP6 text '@@@@@o@@@@@@@@o@@@@@01234g12345 1234o' 60 | GAMEMAP7 text '@@@@@@o@@@@@@o@@@@@@jjjjjjkkkkkll mmmmmo' 61 | GAMEMAP8 text '@@@@@@@o@oooo@@@@@@@nnnnnnooooopp qqqqqo' 62 | GAMEMAP9 text '@@@@@@@@@@@@@@@@@@@@rrrrrrssssstt uuuvvo' 63 | ;============================================================ 64 | ; Program Macros 65 | ;============================================================ 66 | 67 | defm store_values_y ; This macro loads first 68 | lda /1,y ; param then stores in 69 | sta /2 ; second param 70 | lda /3,y ; the loads third and 71 | sta /4 ; stores in forth 72 | endm 73 | 74 | ;============================================================ 75 | ; Check NX or NY (Internal view port x,y) against viewport width,height 76 | ; Reset the value back down (wrap around) by subtracting difference 77 | ; IE if nx>20 then nx=nx-20 78 | ; IE if ny>10 then ny=ny-10 79 | ; This is the code that causes the map to wrap around when 80 | ; moving all the way right or all the way down past the borders 81 | ;============================================================ 82 | defm Check_NXNY 83 | clc 84 | adc /1 85 | sta /2 86 | clc 87 | cmp /3 88 | beq @reset 89 | bcc @bot 90 | @reset sbc /3 91 | sta /2 92 | @bot 93 | endm 94 | 95 | ;============================================================ 96 | ; load param 1 test against param 2 if match reset to param 3 -1 97 | ; storing result in param 1 98 | ; This code keeps the map within the proper boundaries as 99 | ; defined by the map height and map width 100 | ;============================================================ 101 | defm Range_Test 102 | lda /1 103 | clc 104 | cmp /2 105 | bne @bottom 106 | lda /3 107 | sbc #1 108 | sta /1 109 | @bottom 110 | endm 111 | 112 | defm Check_Wrap 113 | clc 114 | adc /1 115 | cmp /2 116 | bcc @skip 117 | sbc /2 118 | @skip 119 | tay 120 | endm 121 | 122 | ;============================================================ 123 | ; PROGRAM START (Grab Keyboard Input) 124 | ;============================================================ 125 | *=$1000 126 | lda #$93 ; shift clear dec 147 127 | jsr $FFD2 ; clear screen 128 | jsr Character_Set 129 | 130 | main_loop jsr move_routine 131 | jsr delay 132 | 133 | @nokey lda Const_KBD_BUFFER ; Input a key from the keyboard 134 | cmp #Const_NOKEY ; Nothing being pressed 135 | beq @nokey 136 | cmp #Const_Qkey ; q key pressed ? 137 | beq quit_prg 138 | cmp #Const_LEFT ; a key pressed? move left 139 | beq move_left ; 140 | cmp #Const_RIGHT ; s key pressed? move right 141 | beq move_right ; 142 | cmp #Const_DOWN ; w key pressed? move up 143 | beq move_up ; 144 | cmp #Const_UP ; z key pressed? move up 145 | bne main_loop ; 146 | move_down inc vy ; Move map down vy=vy+1 147 | Range_Test vy,#Const_gmap_height,#1 ;Test vy for map_height reset to 0 if match 148 | jmp main_loop 149 | move_left dec vx ;Move map left vx=vx-1 150 | Range_Test vx,#$ff,#Const_gmap_width ;Test vx for -1 reset to width if match 151 | jmp main_loop 152 | move_right inc vx ;Move map right vx=vx+1 153 | Range_Test vx,#Const_gmap_width,#1 154 | jmp main_loop 155 | move_up dec vy ;Move map up vy=vy-1 156 | Range_Test vy,#$ff,#Const_gmap_height;Test vy for -1 reset to height if match 157 | jmp main_loop 158 | quit_prg rts 159 | 160 | ;============================================================ 161 | ; MOVEMENT ROUTINE 162 | ; Two loops that draw the map based on the view port vars 163 | ;============================================================ 164 | 165 | move_routine ldy #0 166 | loop_vert store_values_y Const_Screen_L,output+1,Const_Screen_H,output+2 167 | tya 168 | sta tempy+1 169 | Check_Wrap vy,#Const_gmap_height 170 | store_values_y Const_GMAP_L,input+1,Const_GMAP_H,input+2 171 | ldx #0 172 | loop_horiz txa 173 | Check_Wrap vx,#Const_gmap_width 174 | input lda gamemap0,y 175 | output sta $400,x 176 | inx 177 | loop_cpx cpx Const_SCN_View_WD 178 | bne loop_horiz 179 | tempy ldy #$00 180 | iny 181 | cpy #Const_SCN_View_HT 182 | bne loop_vert 183 | rts 184 | ;========================================================== 185 | ; END PROGRAM 186 | ;========================================================== 187 | delay ldy #50 188 | @loop2 ldx #0 189 | @loop dex 190 | bne @loop 191 | dey 192 | bne @loop2 193 | rts 194 | ;========================================================== 195 | ; Redefine Character Set 196 | ;========================================================== 197 | 198 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 199 | 200 | Character_Set 201 | sei ; disable interrupts while we copy 202 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 203 | lda #$33 ; make the CPU see the Character Generator ROM... 204 | sta $01 ; ...at $D000 by storing %00110011 into location $01 205 | lda #$d0 ; load high byte of $D000 206 | sta $fc ; store it in a free location we use as vector 207 | LDA #$30 ; 208 | STA $fe ; 209 | LDA #0 ; 210 | STA $fd 211 | ldy #$00 ; init counter with 0 212 | sty $fb ; store it as low byte in the $FB/$FC vector 213 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 214 | sta ($fd),y ; write to the RAM under ROM at same position 215 | iny ; do this 255 times... 216 | bne loop ; ..for low byte $00 to $FF 217 | inc $fc ; when we passed $FF increase high byte... 218 | inc $fe 219 | dex ; ... and decrease X by one before restart 220 | bne loop ; We repeat this until X becomes Zero 221 | lda #$37 ; switch in I/O mapped registers again... 222 | sta $01 ; ... with %00110111 so CPU can see them 223 | cli ; turn off interrupt disable flag 224 | LDA #28 225 | ; 226 | STA $d018 ; 227 | 228 | ; *********************************************************************************** 229 | ; 230 | 231 | ldx #0 232 | @loop lda water,x 233 | sta $3000,x 234 | inx 235 | cpx #8 236 | bne @loop 237 | 238 | lda #0 239 | sta $400 240 | 241 | ; 242 | setup = * 243 | sei ; disable interrupts 244 | lda #intcode ; do the same with the high byte 247 | sta 789 248 | cli ; re-enable interrupts 249 | rts ; return to caller 250 | rts ; return from subroutine 251 | intcode = * 252 | inc value 253 | lda value 254 | cmp #$a 255 | bne end 256 | lda #0 257 | sta value 258 | lda $3000 259 | sta temp 260 | lda $3001 261 | sta $3000 262 | lda $3002 263 | sta $3001 264 | lda $3003 265 | sta $3002 266 | lda $3004 267 | sta $3003 268 | lda $3005 269 | sta $3004 270 | lda $3006 271 | sta $3005 272 | lda $3007 273 | sta $3006 274 | lda temp 275 | sta $3007 276 | end jmp $ea31 277 | temp byte 00 278 | value byte 00 279 | 280 | ;water BYTE $88,$77,$00,$00,$22,$DD,$00,$00 281 | water BYTE $88,$77,$00,$00,$22,$dd,$00,$00 282 | 283 | ;water BYTE $C6,$31,$8C,$43,$30,$8C,$63,$18 284 | ;water BYTE $30,$0C,$03,$C0,$30,$0C,$03,$C0 285 | ;water BYTE $7E,$81,$7E,$81,$7E,$81,$7E,$81 286 | ;water BYTE $DC,$23,$DC,$22,$9D,$62,$9C,$23 287 | ;water BYTE $F0,$0F,$F0,$0F,$F0,$0F,$F0,$0F 288 | ;water BYTE $CC,$33,$CC,$33,$CC,$33,$CC,$33 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /zef4.asm: -------------------------------------------------------------------------------- 1 | ; Gray Defender 2 | ; 04/11/2015 3 | ; Revised 4 | ; 4/20/2017 5 | ; Rewrote part of the program that displays data on the screen 6 | ; tried to make it more efficient 7 | ; Changed input routine to read kbd from $c5 8 | ; 5/6/2017 9 | ; Added shifting water effect with program interrupt and 10 | ; redefined character set 11 | ; 5/18/17 12 | ; Added printed text output along with scrolling text window 13 | ;============================================================ 14 | ; Quick code to create auto execute program from basic 15 | ;============================================================ 16 | 17 | *=$0801 18 | byte $0c, $08, $0a, $00, $9e, $20 19 | byte $34, $30, $39, $36, $00, $00 20 | byte $00 21 | ;============================================================ 22 | ; Adjustable Variables and constants 23 | ;============================================================ 24 | Const_SCREEN_WD = #40 ;text width of screen (c64) 25 | Const_SCN_View_WD = #15 ;width of view port (viewable on screen) 26 | Const_SCN_View_HT = #10 ;height of view port (viewable on screen) 27 | Const_gmap_width = 40 ;Width of game map data 28 | Const_gmap_height = 10 ;Height of game map data 29 | vx byte 5 ;Starting x position into the game map data 30 | vy byte 5 ;Starting y position into the game map data 31 | ;============================================================ 32 | ; keyboard constants 33 | ;============================================================ 34 | 35 | Const_KBD_BUFFER = $c5 ; 36 | Const_UP = $09 ; 37 | Const_DOWN = $0c ;values 38 | Const_LEFT = $0a ;for up down left right 39 | Const_RIGHT = $0d ; 40 | Const_QKEY = $3e 41 | Const_NOKEY = $40 42 | 43 | ;============================================================ 44 | ; This is done to avoid multiplication through looped addition-->performance 45 | ; If each map row was 20 wide then: 46 | ; 20, 40, 60, 80 etc... until bottom of mapped data 47 | Const_GMAP_L byte GAMEMAP0,>GAMEMAP1,>GAMEMAP2,>GAMEMAP3,>GAMEMAP4,>GAMEMAP5,>GAMEMAP6,>GAMEMAP7,>GAMEMAP8,>GAMEMAP9 49 | Const_Screen_L byte $00,$28,$50,$78,$A0,$C8,$F0,$18,$40,$68,$90,$b8,$E0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0 50 | Const_Screen_H byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07 51 | ;============================================================ 52 | ; ******* G A M E M A P ******* 53 | ;============================================================ 54 | 55 | GAMEMAP0 text '@@@@@gray defender@@xxxxxxxxxxxxx xxxxxo' 56 | GAMEMAP1 text '@@@@@@@owooot @@@@@@xxxxxxxxxxxxx xxxxxo' 57 | GAMEMAP2 text '@@@@@o@@@@@@oo@@@@@@xxxxvvvvxxx xxo' 58 | GAMEMAP3 text '@@@@o@@@@@@@@@o@@@@@xxxxxxvvvxxxxxxx xxo' 59 | GAMEMAP4 text '@@@o@o@@@@@@@@@oo@@@xxxxxxxxxxx xxo' 60 | GAMEMAP5 text '@@@@o@@@HI@@@@@o@@@@aaabbbcccdd eeefffgo' 61 | GAMEMAP6 text '@@@@@o@@@@@@@@o@@@@@01234g12345 1234o' 62 | GAMEMAP7 text '@@@@@@o@@@@@@o@@@@@@jjjjjjkkkkkll mmmmmo' 63 | GAMEMAP8 text '@@@@@@@o@oooo@@@@@@@nnnnnnooooopp qqqqqo' 64 | GAMEMAP9 text '@@@@@@@@@@@@@@@@@@@@rrrrrrssssstt uuuvvo' 65 | ;============================================================ 66 | ; Program Macros 67 | ;============================================================ 68 | defm store_values ; This macro loads first 69 | lda /1,y ; param then stores in 70 | sta /2 ; second param 71 | lda /3,y ; the loads third and 72 | sta /4 ; stores in forth 73 | endm 74 | 75 | defm shift_window 76 | lda /1 77 | sta WIN_X 78 | lda /2 79 | sta WIN_Y 80 | lda /3 81 | sta WD 82 | lda /4 83 | sta HT 84 | jsr Scroll_Window_Up 85 | endm 86 | 87 | defm Print_Text 88 | 89 | lda #/1 92 | sta main_string+2 93 | jsr Display_Text 94 | endm 95 | defm store_values_y ; This macro loads first 96 | lda /1,y ; param then stores in 97 | sta /2 ; second param 98 | lda /3,y ; the loads third and 99 | sta /4 ; stores in forth 100 | endm 101 | 102 | ;============================================================ 103 | ; Check NX or NY (Internal view port x,y) against viewport width,height 104 | ; Reset the value back down (wrap around) by subtracting difference 105 | ; IE if nx>20 then nx=nx-20 106 | ; IE if ny>10 then ny=ny-10 107 | ; This is the code that causes the map to wrap around when 108 | ; moving all the way right or all the way down past the borders 109 | ;============================================================ 110 | defm Check_NXNY 111 | clc 112 | adc /1 113 | sta /2 114 | clc 115 | cmp /3 116 | beq @reset 117 | bcc @bot 118 | @reset sbc /3 119 | sta /2 120 | @bot 121 | endm 122 | 123 | ;============================================================ 124 | ; load param 1 test against param 2 if match reset to param 3 -1 125 | ; storing result in param 1 126 | ; This code keeps the map within the proper boundaries as 127 | ; defined by the map height and map width 128 | ;============================================================ 129 | defm Range_Test 130 | lda /1 131 | clc 132 | cmp /2 133 | bne @bottom 134 | lda /3 135 | sbc #1 136 | sta /1 137 | @bottom 138 | endm 139 | 140 | defm Check_Wrap 141 | clc 142 | adc /1 143 | cmp /2 144 | bcc @skip 145 | sbc /2 146 | @skip 147 | tay 148 | endm 149 | 150 | ;============================================================ 151 | ; PROGRAM START (Grab Keyboard Input) 152 | ;============================================================ 153 | *=$1000 154 | lda #$93 ; shift clear dec 147 155 | jsr $FFD2 ; clear screen 156 | jsr Character_Set 157 | 158 | main_loop jsr move_routine 159 | jsr delay 160 | 161 | @nokey lda Const_KBD_BUFFER ; Input a key from the keyboard 162 | cmp #Const_NOKEY ; Nothing being pressed 163 | beq @nokey 164 | cmp #Const_Qkey ; q key pressed ? 165 | beq quit_prg 166 | cmp #Const_LEFT ; a key pressed? move left 167 | beq move_left ; 168 | cmp #Const_RIGHT ; s key pressed? move right 169 | beq move_right ; 170 | cmp #Const_DOWN ; w key pressed? move up 171 | beq _move_up ; 172 | cmp #Const_UP ; z key pressed? move up 173 | bne main_loop ; 174 | move_down inc vy ; Move map down vy=vy+1 175 | Range_Test vy,#Const_gmap_height,#1 ;Test vy for map_height reset to 0 if match 176 | shift_window #5,#15,#10,#5 177 | Print_Text str_south 178 | 179 | jmp main_loop 180 | _move_up jmp move_up 181 | quit_prg rts 182 | move_left dec vx ;Move map left vx=vx-1 183 | Range_Test vx,#$ff,#Const_gmap_width;Test vx for -1 reset to width if match 184 | shift_window #5,#15,#10,#5 185 | Print_Text str_west 186 | 187 | jmp main_loop 188 | move_right inc vx ;Move map right vx=vx+1 189 | Range_Test vx,#Const_gmap_width,#1 190 | shift_window #5,#15,#10,#5 191 | Print_Text str_east 192 | 193 | jmp main_loop 194 | move_up dec vy ;Move map up vy=vy-1 195 | Range_Test vy,#$ff,#Const_gmap_height;Test vy for -1 reset to height if match 196 | 197 | shift_window #5,#15,#10,#5 198 | Print_Text str_north 199 | 200 | 201 | jmp main_loop 202 | 203 | 204 | ;============================================================ 205 | ; MOVEMENT ROUTINE 206 | ; Two loops that draw the map based on the view port vars 207 | ;============================================================ 208 | 209 | move_routine ldy #0 210 | loop_vert store_values_y Const_Screen_L,output+1,Const_Screen_H,output+2 211 | tya 212 | sta tempy+1 213 | Check_Wrap vy,#Const_gmap_height 214 | store_values_y Const_GMAP_L,input+1,Const_GMAP_H,input+2 215 | ldx #0 216 | loop_horiz txa 217 | Check_Wrap vx,#Const_gmap_width 218 | input lda gamemap0,y 219 | output sta $400,x 220 | inx 221 | loop_cpx cpx Const_SCN_View_WD 222 | bne loop_horiz 223 | tempy ldy #$00 224 | iny 225 | cpy #Const_SCN_View_HT 226 | bne loop_vert 227 | rts 228 | ;========================================================== 229 | ; END PROGRAM 230 | ;========================================================== 231 | delay ldy #50 232 | @loop2 ldx #0 233 | @loop dex 234 | bne @loop 235 | dey 236 | bne @loop2 237 | rts 238 | ;========================================================== 239 | ; Window SUBS 240 | ;========================================================== 241 | Scroll_Window_Up 242 | ldy WIN_Y 243 | iny 244 | clc 245 | lda WIN_X 246 | adc WD 247 | sta MAX_WIDTH 248 | clc 249 | lda WIN_Y 250 | adc HT 251 | sta max_ht+1 252 | loop_scr ldx WIN_X 253 | store_values Const_Screen_H,input_scr+2,Const_Screen_L,input_scr+1 254 | store_values Const_Screen_H,lastline+2,Const_Screen_L,lastline+1 255 | dey 256 | store_values Const_Screen_H,output_scr+2,Const_Screen_L,output_scr+1 257 | iny 258 | input_scr lda $428,x 259 | output_scr sta $400,x 260 | lda #$20 261 | lastline sta $428,x 262 | inx 263 | cpx MAX_WIDTH 264 | bne input_scr 265 | iny 266 | max_ht cpy #10 267 | bne loop_scr 268 | rts 269 | 270 | Display_Text 271 | lda #0 272 | sta string_pos 273 | Top_loop clc ; Set Cursor Position 274 | ldx max_ht+1 ; 275 | dex ; 276 | ldy WIN_X ; 277 | jsr $e50a ; X=Row, Y=Column 278 | ldx #0 279 | loop123 ldy string_pos 280 | main_string lda $ffff,y 281 | beq @exit_loop 282 | jsr $ffd2 283 | inx 284 | inc string_pos 285 | cpx WD 286 | bne loop123 287 | jsr Scroll_Window_Up 288 | jmp Top_loop 289 | @exit_loop 290 | rts 291 | str_north null ">NORTH" 292 | str_south null ">SOUTH" 293 | str_east null ">EAST" 294 | str_west null ">WEST" 295 | 296 | string_pos byte 00 297 | WIN_X byte 0 298 | WIN_Y byte 0 299 | WD byte 40 300 | HT byte 25 301 | MAX_WIDTH byte 00 ; Starting position plus width of window 302 | 303 | ;========================================================== 304 | ; Redefine Character Set 305 | ;========================================================== 306 | 307 | ;http://dustlayer.com/vic-ii/2013/4/23/vic-ii-for-beginners-part-2-to-have-or-to-not-have-character 308 | 309 | Character_Set 310 | sei ; disable interrupts while we copy 311 | ldx #$08 ; we loop 8 times (8x255 = 2Kb) 312 | lda #$33 ; make the CPU see the Character Generator ROM... 313 | sta $01 ; ...at $D000 by storing %00110011 into location $01 314 | lda #$d0 ; load high byte of $D000 315 | sta $fc ; store it in a free location we use as vector 316 | LDA #$30 ; 317 | STA $fe ; 318 | LDA #0 ; 319 | STA $fd 320 | ldy #$00 ; init counter with 0 321 | sty $fb ; store it as low byte in the $FB/$FC vector 322 | loop lda ($fb),y ; read byte from vector stored in $fb/$fc 323 | sta ($fd),y ; write to the RAM under ROM at same position 324 | iny ; do this 255 times... 325 | bne loop ; ..for low byte $00 to $FF 326 | inc $fc ; when we passed $FF increase high byte... 327 | inc $fe 328 | dex ; ... and decrease X by one before restart 329 | bne loop ; We repeat this until X becomes Zero 330 | lda #$37 ; switch in I/O mapped registers again... 331 | sta $01 ; ... with %00110111 so CPU can see them 332 | cli ; turn off interrupt disable flag 333 | LDA #28 334 | ; 335 | STA $d018 ; 336 | 337 | ; *********************************************************************************** 338 | ; 339 | 340 | ldx #0 341 | @loop lda water,x 342 | sta $3000,x 343 | inx 344 | cpx #8 345 | bne @loop 346 | 347 | lda #0 348 | sta $400 349 | 350 | ; 351 | setup = * 352 | sei ; disable interrupts 353 | lda #intcode ; do the same with the high byte 356 | sta 789 357 | cli ; re-enable interrupts 358 | rts ; return to caller 359 | rts ; return from subroutine 360 | intcode = * 361 | inc value 362 | lda value 363 | cmp #$a 364 | bne end 365 | lda #0 366 | sta value 367 | lda $3000 368 | sta temp 369 | lda $3001 370 | sta $3000 371 | lda $3002 372 | sta $3001 373 | lda $3003 374 | sta $3002 375 | lda $3004 376 | sta $3003 377 | lda $3005 378 | sta $3004 379 | lda $3006 380 | sta $3005 381 | lda $3007 382 | sta $3006 383 | lda temp 384 | sta $3007 385 | end jmp $ea31 386 | temp byte 00 387 | value byte 00 388 | 389 | ;water BYTE $88,$77,$00,$00,$22,$DD,$00,$00 390 | water BYTE $88,$77,$00,$00,$22,$dd,$00,$00 391 | 392 | ;water BYTE $C6,$31,$8C,$43,$30,$8C,$63,$18 393 | ;water BYTE $30,$0C,$03,$C0,$30,$0C,$03,$C0 394 | ;water BYTE $7E,$81,$7E,$81,$7E,$81,$7E,$81 395 | ;water BYTE $DC,$23,$DC,$22,$9D,$62,$9C,$23 396 | ;water BYTE $F0,$0F,$F0,$0F,$F0,$0F,$F0,$0F 397 | ;water BYTE $CC,$33,$CC,$33,$CC,$33,$CC,$33 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | --------------------------------------------------------------------------------