├── .gitignore ├── Readme.md ├── megadrive ├── debuggers │ ├── .gitignore │ └── Readme.md ├── projects │ └── Readme.md ├── tools │ └── Readme.md └── tutorials │ ├── add-instruction │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── addressing-modes-1 │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── addressing-modes-2 │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── addressing-modes-absolute-short │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── addressing-modes-absolute │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── addx │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── algorithm-find-number-in-array │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── bass-megadrive-test │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── branching1 │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── cmp │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── comrade │ └── comrade.bin │ ├── endianess │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── ext-instruction │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── ifelse │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── loop-for │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── loop-while │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ ├── move-instruction │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ │ └── .gitignore │ └── overflow │ ├── build.bat │ ├── header.megadrive.asm │ ├── main.asm │ └── main │ └── .gitignore ├── snes ├── debuggers │ ├── .gitignore │ └── Readme.md ├── projects │ └── Readme.md ├── tools │ └── Readme.md └── tutorials │ ├── 8bits-16bits-modes │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── adc-64bits │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── adc-instructions │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── addressing-modes-1 │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── addressing-modes-2 │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── addressing-modes-absolute │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── bass-snes-test │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── branching1 │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── cmp │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── data-size │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── endian │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── ifelse │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── loop-for │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── loop-while │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── move-instructions │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ ├── overflow │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ ├── header.snes.asm │ ├── main.asm │ └── main.sfc │ │ └── .gitignore │ └── simpsons │ ├── build-bsnes-plus.bat │ ├── build-v086.bat │ └── main.sfc │ ├── .gitignore │ └── main.sfc └── tools └── Readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | **/tempbasslsp.bin 2 | **/.tempbasslsp.bin -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ## Programming with Old Consoles 2 | 3 | This repository contains all the projects, tutorials and tools used in the playlist about programming with old consoles from the youtube channels "Manual do Código" and "Programming With Doug". 4 | 5 | 6 | -------------------------------------------------------------------------------- /megadrive/debuggers/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !Readme.md -------------------------------------------------------------------------------- /megadrive/debuggers/Readme.md: -------------------------------------------------------------------------------- 1 | ## Sega Genesis Debuggers 2 | 3 | In this folder we need to add all the emulators used for Sega Genesis projects. 4 | 5 | You need to download the last releases from the following repositories: 6 | 7 | [https://github.com/Dgdiniz/Exodus](https://github.com/Dgdiniz/Exodus) 8 | 9 | After the download, extract the folders to have the following folders: 10 | 11 | - Exodus 12 | 13 | The build scripts will look for these folders, so make sure you have the right structure. 14 | 15 | -------------------------------------------------------------------------------- /megadrive/projects/Readme.md: -------------------------------------------------------------------------------- 1 | ## Tools 2 | 3 | This folder contains all Mega Drive/Sega Genesis projects. 4 | 5 | -------------------------------------------------------------------------------- /megadrive/tools/Readme.md: -------------------------------------------------------------------------------- 1 | ## Tools 2 | 3 | This folder contains all tools used in the Mega Drive/Sega Genesis projects. 4 | 5 | -------------------------------------------------------------------------------- /megadrive/tutorials/add-instruction/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/add-instruction/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/add-instruction/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #$12345678,d0 18 | move.l #$beef1000,d1 19 | add.l d1,d0 20 | 21 | move.w #$1000,d0 22 | add.w d1,d0 23 | 24 | move.b #$a0,d0 25 | move.b #$f3,d1 26 | add.b d1,d0 27 | 28 | move.l #$12345678,$ff0000 29 | 30 | add.l #$00001000,d0 31 | addi.l #$00001000,d0 32 | addi.l #$00001000,$ff0000 33 | add.l #$00001000,$ff0000 //invalido 34 | addi.w #$f000,$ff0000 35 | 36 | move.l #$11111111,$ff0010 37 | movea.l #$00ff0000,a0 38 | 39 | adda.l #$10,a0 40 | add.l #$1000,(a0) //invalido 41 | addi.l #$1000,(a0) 42 | 43 | addq.b #$5,d0 44 | 45 | move.b #$ff,d1 46 | addq.b #$3,d1 47 | movea.l a0,a1 48 | addq.l #$1,a1 49 | 50 | move.l #$ffffff00,d2 51 | add.l #$ffffff00,d2 52 | 53 | //sub 54 | 55 | move.l #$00001000,d4 56 | sub.l #$00001000,d4 57 | 58 | move.l #$00001000,d4 59 | subi.w #$3000,d4 60 | 61 | subi.w #$3000,(a0) 62 | 63 | suba.l #$10,a0 64 | subi.b #$20,(a0) 65 | 66 | subq.w #$1,d0 67 | 68 | 69 | -; bra - -------------------------------------------------------------------------------- /megadrive/tutorials/add-instruction/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-1/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-1/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | //Immediate and Data Register Direct 18 | move.l #$10204fff,d0 19 | move.l #$1034f88a,d3 20 | 21 | //Both Data Register Direct 22 | move.b d0,d3 23 | 24 | //Immediate and Address Register Direct 25 | movea.l #$00200000,a0 26 | 27 | //Both Address Register Direct 28 | movea.l a0,a3 29 | 30 | 31 | gameover: 32 | -; bra - 33 | 34 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-1/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-2/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-2/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | //Immediate and Absolute Long 18 | move.l #$12345678,$ff0000 19 | move.b #$05,$ff000.l 20 | move.w #$aabb,($ff000).l 21 | 22 | //Both Absolute Long 23 | move.b $1000,$ff0000 24 | 25 | //Invalid. Must be the same format in both parameters. This is a Bass limitation. 26 | //move.b $1000,$ff0000.l 27 | 28 | //This is valid because both paremeters has the same syntax 29 | move.b $1000.l,$ff0000.l 30 | 31 | //Immediate and Absolute Long 32 | move.l #$deadbeef,$ff8000 33 | 34 | //Absolute Short and Absolute Long 35 | move.l $1000.w,($ff0000).l 36 | move.l $8000.w,$ff0000.l 37 | 38 | //Absolute Long 39 | move.l $8000,$ff0000 40 | 41 | //Both Absolute Short 42 | move.l $1000.w,$c000.w 43 | 44 | //Bass doesn't optimize. 45 | move.l #1,$ff8000 46 | move.l #1,$8000.w 47 | 48 | 49 | gameover: 50 | -; bra - 51 | 52 | seek($1000) 53 | dl $9abcdef0 54 | 55 | seek(8000) 56 | dl $aabbccdd 57 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-2/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-absolute-short/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-absolute-short/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | //Absolute Long 18 | move.l $8000,$8000.w 19 | 20 | //Both Absolute Short 21 | move.l $1000.w,$c000.w 22 | 23 | //Bass doesn't optimize. 24 | move.l #1,$ff8000 25 | move.l #1,$8000.w 26 | 27 | gameover: 28 | -; bra - 29 | 30 | seek($1000) 31 | dd $9abcdef0 32 | 33 | seek($8000) 34 | dd $aabbccdd 35 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-absolute-short/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-absolute/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-absolute/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | //Immediate and Absolute Long 18 | move.l #$12345678,$ff0000 19 | move.b #$05,$ff0000.l 20 | move.w #$aabb,($ff0000).l 21 | 22 | //Both Absolute Long 23 | move.b $1000,$ff0000 24 | 25 | //Invalid. Must be the same format in both parameters. This is a Bass limitation. 26 | //move.b $1000,$ff0000.l 27 | 28 | //This is valid because both paremeters has the same syntax 29 | move.b $1000.l,$ff0000.l 30 | 31 | //Immediate and Absolute Long 32 | move.l #$deadbeef,$ff8000 33 | 34 | gameover: 35 | -; bra - 36 | 37 | seek($1000) 38 | dd $9abcdef0 39 | 40 | seek($8000) 41 | dd $aabbccdd 42 | -------------------------------------------------------------------------------- /megadrive/tutorials/addressing-modes-absolute/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/addx/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/addx/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/addx/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($204) 14 | nop 15 | 16 | //Adding 64bits with add only (wrong, but works!) 17 | move.l #$12345678,d0 18 | move.l #$9abcdef0,d1 19 | move.l #$11223344,d2 20 | move.l #$55667788,d3 21 | add.l d1,d3 22 | add.l d0,d2 23 | 24 | //Adding 64bits with add only (wrong, but works!) 25 | move.l #$12345678,$ff0000 26 | move.l #$9abcdef0,$ff0004 27 | move.l #$11223344,$ff0010 28 | move.l #$55667788,$ff0014 29 | movea.l #$ff0008,a0 30 | movea.l #$ff0018,a1 31 | move.l -(a0),d0 32 | add.l d0,-(a1) 33 | move.l -(a0),d0 34 | add.l d0,-(a1) 35 | 36 | //Adding 64bits with add only (wrong!) 37 | move.l #$fedcba98,$ff0000 38 | move.l #$76543210,$ff0004 39 | move.l #$88776655,$ff0010 40 | move.l #$ffeeddcc,$ff0014 41 | movea.l #$ff0008,a0 42 | movea.l #$ff0018,a1 43 | move.l -(a0),d0 44 | add.l d0,-(a1) 45 | move.l -(a0),d0 46 | add.l d0,-(a1) 47 | 48 | //Adding 64bits with addx (right way!) 49 | move.l #$fedcba98,$ff0000 50 | move.l #$76543210,$ff0004 51 | move.l #$88776655,$ff0010 52 | move.l #$ffeeddcc,$ff0014 53 | movea.l #$ff0008,a0 54 | movea.l #$ff0018,a1 55 | move.w #$0004,ccr 56 | addx.l -(a0),-(a1) 57 | addx.l -(a0),-(a1) 58 | 59 | //Adding 64bits with addx (right way!) 60 | move.l #$ffffffff,$ff0000 61 | move.l #$76543210,$ff0004 62 | move.l #$00000000,$ff0010 63 | move.l #$ffeeddcc,$ff0014 64 | movea.l #$ff0008,a0 65 | movea.l #$ff0018,a1 66 | move.w #$0004,ccr 67 | addx.l -(a0),-(a1) 68 | addx.l -(a0),-(a1) 69 | 70 | //Adding 64bits with addx (right way!) 71 | move.l #$ffffffff,$ff0000 72 | move.l #$80000000,$ff0004 73 | move.l #$00000000,$ff0010 74 | move.l #$80000000,$ff0014 75 | movea.l #$ff0008,a0 76 | movea.l #$ff0018,a1 77 | move.w #$0004,ccr 78 | addx.l -(a0),-(a1) 79 | addx.l -(a0),-(a1) 80 | 81 | //Adding 64bits with addx and add 82 | move.l #$ffffffff,d0 83 | move.l #$80000000,d1 84 | move.l #$00000000,d2 85 | move.l #$80000000,d3 86 | add.l d1,d3 87 | addx.l d0,d2 88 | 89 | //Negation 90 | move.l #$12345678,d0 91 | neg.l d0 92 | 93 | //Negation of a 64bits 94 | move.l #$12345678,$ff0000 95 | move.l #$9abcdef0,$ff0004 96 | move.w #$0004,ccr 97 | negx.l $ff0004 98 | negx.l $ff0000 99 | 100 | //Negation of a 64bits 101 | move.l #$00000000,$ff0000 102 | move.l #$12345678,$ff0004 103 | move.w #$0004,ccr 104 | negx.l $ff0004 105 | negx.l $ff0000 106 | 107 | //Negation of a 64bits 108 | move.l #$00000000,$ff0000 109 | move.l #$00000000,$ff0004 110 | move.w #$0004,ccr 111 | negx.l $ff0004 112 | negx.l $ff0000 113 | 114 | -;jmp - 115 | 116 | -------------------------------------------------------------------------------- /megadrive/tutorials/addx/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/algorithm-find-number-in-array/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/algorithm-find-number-in-array/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #9,d0 18 | movea.l #$1000,a0 19 | loop: 20 | cmp.b #5,(a0)+ 21 | dbgt d0,loop 22 | 23 | next: 24 | sub.l #$1,a0 25 | nop 26 | gameover: 27 | -; bra - 28 | 29 | seek($1000) 30 | db 10, 8, $23, -6, $14, $36, 1, -3, -16, 31 31 | 32 | 33 | -------------------------------------------------------------------------------- /megadrive/tutorials/algorithm-find-number-in-array/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/bass-megadrive-test/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/bass-megadrive-test/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | rte 16 | 17 | seek($204) 18 | move.l #$11223344,d0 19 | - 20 | addi.b #$01,d0 21 | bra - -------------------------------------------------------------------------------- /megadrive/tutorials/bass-megadrive-test/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/branching1/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/branching1/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/branching1/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #$00000001,d0 18 | label1: 19 | add.l #$00000001,d0 20 | bra label2 21 | -; nop 22 | nop 23 | nop 24 | jmp + 25 | label2: 26 | add.l #$00000002,d0 27 | bra - 28 | +; add.l #$00000001,d0 29 | jmp $00000200 30 | 31 | -; bra - 32 | 33 | -------------------------------------------------------------------------------- /megadrive/tutorials/branching1/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/cmp/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/cmp/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/cmp/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #$12345678,d0 18 | move.l #$9abcde78,d1 19 | move.l #$ff0000,a0 20 | move.l #$ff0004,a1 21 | move.l d0,(a0) 22 | move.l d1,(a1) 23 | 24 | // Register <-> Register ------------------------------------------------- 25 | 26 | move.w #0,ccr 27 | cmp.l d0,d1 // 32bits - The values are different 28 | 29 | move.w #0,ccr 30 | cmp.l d1,d0 // 32bits - The values are different 31 | 32 | move.w #0,ccr 33 | cmp.w d0,d1 // 16bits - The values are different 34 | 35 | move.w #0,ccr 36 | cmp.b d0,d1 // 8bits - The values are the same 37 | 38 | 39 | // Memory <-> Register --------------------------------------------------- 40 | 41 | move.w #0,ccr 42 | cmp.l (a0),d1 // 32bits - The values are different 43 | 44 | move.w #0,ccr 45 | cmp.w (a0),d1 // 16bits - The values are different 46 | 47 | move.w #0,ccr 48 | cmp.b (a0),d1 // 8bits - The values are the same 49 | 50 | 51 | // Immediate <-> Register ------------------------------------------------ 52 | 53 | move.w #0,ccr 54 | cmpi.l #$12345678,d0 // 32bits - The values are the same 55 | 56 | move.w #0,ccr 57 | cmp.w #$beef,d0 // 16bits - The values are different 58 | 59 | move.w #0,ccr 60 | cmpi.b #$78,d0 // 8bits - The values are the same 61 | 62 | 63 | // Register <-> Address Register ------------------------------------------ 64 | 65 | move.w #0,ccr 66 | move.l #$ff0000,a3 67 | cmpa.l #$ff0000,a3 68 | 69 | move.w #0,ccr 70 | move.l #$ff0000,$ff0010 71 | cmp.l $ff0010,a3 72 | 73 | 74 | // Memory <-> Memory ----------------------------------------------------- 75 | 76 | movea.l #$ff0020,a4 77 | movea.l #$ff0030,a5 78 | 79 | move.l #$12345678,$ff0020 80 | move.l #$9abcdef0,$ff0024 81 | 82 | move.l #$12345678,$ff0030 83 | move.l #$9abcdef1,$ff0034 84 | 85 | clr.l d6 86 | 87 | -; cmp.b (a4)+,(a5)+ 88 | bne gameover 89 | add.l #1,d6 90 | bra - 91 | 92 | gameover: 93 | -; bra - 94 | 95 | -------------------------------------------------------------------------------- /megadrive/tutorials/cmp/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/comrade/comrade.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dgdiniz/retro-level-programming/bbd9d91df5e128ee1844d54b100061543800a817/megadrive/tutorials/comrade/comrade.bin -------------------------------------------------------------------------------- /megadrive/tutorials/endianess/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/endianess/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/endianess/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | //Gravando long word, word e byte 18 | move.l #$12345678,d0 19 | move.l #$12345678,$ff0000 20 | 21 | move.w #$1234,d1 22 | move.w #$1234,$ff0010 23 | 24 | move.b #$12,d2 25 | move.b #$12,$ff0020 26 | 27 | //Cuidado aqui!!! 28 | move.l #$2,$ff0030 29 | move.w $ff0030,d4 30 | 31 | -; bra - 32 | 33 | -------------------------------------------------------------------------------- /megadrive/tutorials/endianess/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/ext-instruction/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/ext-instruction/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/ext-instruction/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #$80,d0 18 | 19 | ext.w d0 20 | ext.l d0 21 | 22 | move.l #$12345678,d0 23 | ext d0 24 | 25 | move.l #$fedcba98,d0 26 | ext.l d0 27 | 28 | gameover: 29 | -; bra - 30 | 31 | -------------------------------------------------------------------------------- /megadrive/tutorials/ext-instruction/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/ifelse/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/ifelse/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/ifelse/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | constant varEnergyPtr = $ff1000 14 | 15 | seek($200) 16 | nop 17 | nop 18 | 19 | move.w #$0008,varEnergyPtr // Player's Energy 20 | 21 | gameloop: 22 | // Instructions before the if 23 | move.w varEnergyPtr,d1 24 | 25 | 26 | //////// if ///////////////////////// 27 | cmp.w #5,d1 28 | bne next_if1 29 | //play caution sound 30 | nop 31 | nop 32 | next_if1: 33 | ///////////////////////////////////// 34 | 35 | nop 36 | 37 | //////// if-else //////////////////// 38 | cmp.w #3,d1 39 | bpl _else 40 | //draw red screen 41 | nop 42 | nop 43 | bra next_if2 44 | _else: 45 | //draw blue screen 46 | nop 47 | nop 48 | next_if2: 49 | ///////////////////////////////////// 50 | 51 | nop 52 | 53 | //////// if-else //////////////////// 54 | //If energy is 0, game over 55 | cmp.w #0,d1 56 | beq gameover 57 | 58 | //Else, decrement energy 59 | subi.w #1,d1 60 | move.w d1,varEnergyPtr 61 | bra gameloop 62 | ///////////////////////////////////// 63 | 64 | gameover: 65 | -; bra - 66 | 67 | -------------------------------------------------------------------------------- /megadrive/tutorials/ifelse/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/loop-for/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/loop-for/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/loop-for/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #$0,d0 18 | loop_for: 19 | cmp #$5,d0 20 | bge + 21 | nop 22 | nop 23 | nop 24 | add #$1,d0 25 | bra loop_for 26 | 27 | +;nop 28 | 29 | 30 | move.w #4,d0 31 | loop_for2: 32 | nop 33 | nop 34 | nop 35 | dbra d0,loop_for2 36 | 37 | gameover: 38 | -; bra - 39 | 40 | -------------------------------------------------------------------------------- /megadrive/tutorials/loop-for/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/loop-while/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/loop-while/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/loop-while/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.l #$5,d0 18 | 19 | // Normal while ///////////// 20 | while: 21 | cmp.l #0,d0 22 | beq + 23 | nop 24 | sub #1,d0 25 | nop 26 | bra while 27 | ///////////////////////////// 28 | 29 | +; nop 30 | 31 | move.l #$5,d0 32 | 33 | // do/while ///////////////// 34 | dowhile: 35 | nop 36 | sub #1,d0 37 | nop 38 | cmp.l #0,d0 39 | bne dowhile 40 | ///////////////////////////// 41 | 42 | nop 43 | 44 | gameover: 45 | -; bra - 46 | 47 | -------------------------------------------------------------------------------- /megadrive/tutorials/loop-while/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/move-instruction/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/move-instruction/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | move #$12345678,d0 17 | move.l #$12345678,d0 18 | move.w #$abcd,d0 19 | move.b #$dd,d0 20 | 21 | move d0,d1 22 | move.l d0,d2 23 | move.w d2,d3 24 | move.b d3,d4 25 | 26 | move.l d0,$ff0000 27 | move.w d1,$ff0008 28 | move.b d2,$ff0010 29 | 30 | move.l #$aabbccdd,$ff0018 31 | move.w $ff0018,d5 32 | 33 | move.l $ff0018,$ff0020 34 | move.w $ff0018,$ff0028 35 | move.b $ff0018,$ff0030 36 | 37 | movea.l #$ff0040,a0 38 | movea.w #$1234,a1 39 | movea.w #$8abc,a2 40 | move.w #$8000,a3 41 | move.w d0,a4 42 | 43 | move.l #$deadbeef,d0 44 | move.l d0,(a0) 45 | 46 | move.b #$22,d6 47 | 48 | move.b d6,(a0)+ 49 | move.b d6,(a0)+ 50 | move.b d6,(a0)+ 51 | move.b d6,(a0)+ 52 | 53 | moveq #$45,d0 54 | moveq #$85,d0 55 | moveq #$c2,d2 56 | 57 | move.l #$00,d0 58 | move.w #$8000,d0 59 | move.l #$00,d1 60 | move.l #10,d1 61 | move.l #-10,d1 62 | move.b #$00,d2 63 | move.b #$a1,d2 64 | move.w #$1000,$ff0050 65 | move.w #$8000,$ff0050 66 | move.b #$80,$ff0058 67 | 68 | exg.l d0,d1 69 | exg.l a0,a1 70 | exg d2,d3 71 | exg.l d1,a0 72 | exg d2,a1 73 | 74 | 75 | -; bra - 76 | -------------------------------------------------------------------------------- /megadrive/tutorials/move-instruction/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /megadrive/tutorials/overflow/build.bat: -------------------------------------------------------------------------------- 1 | bass -o main\main.bin main.asm 2 | cd ..\..\debuggers\Exodus 3 | Exodus.exe 4 | -------------------------------------------------------------------------------- /megadrive/tutorials/overflow/header.megadrive.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // Mega Drive Header 3 | //============= 4 | 5 | //VECTOR TABLE - $00000000-$000000FF 6 | seek($00) 7 | dd $00000200 // STACK POINTER 8 | dd $00000204 // CODE START 9 | dd $00000200 // BUS ERROR 10 | dd $00000200 // ADDRESS ERROR 11 | dd $00000200 // ILLEGAL INSTRUCTION 12 | dd $00000200 // CHK EXCEPTION 13 | dd $00000200 // TRAPV EXCEPTION 14 | dd $00000200 // PRIVILEGE VIOLATION 15 | dd $00000200 // TRACE EXCEPTION 16 | dd $00000200 // LINE 1010 EMULATOR 17 | dd $00000200 // LINE 1111 EMULATOR 18 | // $30-$5F IS RESERVED BY MOTOROLA 19 | seek($60) 20 | dd $00000200 // SPURIOUS EXCEPTION 21 | dd $00000200 // INTERRUPT REQUEST LEVEL 1 22 | dd $00000200 // INTERRUPT REQUEST LEVEL 2 23 | dd $00000200 // INTERRUPT REQUEST LEVEL 3 24 | dd $00000200 // INTERRUPT REQUEST LEVEL 4 (VDP INTERRUPT / HORIZONTAL BLANK) 25 | dd $00000200 // INTERRUPT REQUEST LEVEL 5 26 | dd $00000200 // INTERRUPT REQUEST LEVEL 6 (VERTICAL BLANK) 27 | dd $00000200 // INTERRUPT REQUEST LEVEL 7 28 | dd $00000200 // TRAP #00 EXCEPTION 29 | dd $00000200 // TRAP #01 EXCEPTION 30 | dd $00000200 // TRAP #02 EXCEPTION 31 | dd $00000200 // TRAP #03 EXCEPTION 32 | dd $00000200 // TRAP #04 EXCEPTION 33 | dd $00000200 // TRAP #05 EXCEPTION 34 | dd $00000200 // TRAP #06 EXCEPTION 35 | dd $00000200 // TRAP #07 EXCEPTION 36 | dd $00000200 // TRAP #08 EXCEPTION 37 | dd $00000200 // TRAP #09 EXCEPTION 38 | dd $00000200 // TRAP #10 EXCEPTION 39 | dd $00000200 // TRAP #11 EXCEPTION 40 | dd $00000200 // TRAP #12 EXCEPTION 41 | dd $00000200 // TRAP #13 EXCEPTION 42 | dd $00000200 // TRAP #14 EXCEPTION 43 | dd $00000200 // TRAP #15 EXCEPTION 44 | // $C0-$FF IS RESERVED BY MOTOROLA 45 | 46 | 47 | seek($100) 48 | 49 | // SYSTEM TYPE 50 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 51 | // 52 | // What system the game is running on. 53 | // For the Mega Drive, it usually would be "SEGA MEGA DRIVE" or "SEGA GENESIS". 54 | // Some flashcarts enable extra functionality if a specific text is found here. 55 | // 56 | // All known system types so far: 57 | // "SEGA MEGA DRIVE" | Mega Drive 58 | // "SEGA GENESIS" | Mega Drive 59 | // "SEGA 32X" | Mega Drive + 32X 60 | // "SEGA EVERDRIVE" | Mega Drive (Everdrive extensions) 61 | // "SEGA SSF" | Mega Drive (Mega Everdrive extensions) 62 | // "SEGA MEGAWIFI" | Mega Drive (Mega Wifi extensions) 63 | // "SEGA PICO" | Pico 64 | // "SEGA TERA68K" | Tera Drive (boot from 68000 side) 65 | // "SEGA TERA286" | Tera Drive (boot from x86 side) 66 | // 67 | db "SEGA MEGA DRIVE " 68 | // "1234567890123456" 69 | 70 | 71 | //COPYRIGHT AND RELEASE DATE 72 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 73 | // 74 | // A field with the format "(C)XXXX YYYY.ZZZ", where: 75 | // "XXXX" | Publisher 76 | // "YYYY" | Release year 77 | // "ZZZ" | Release month 78 | // 79 | // The "XXXX" part is a four-character abbreviation that identifies the publisher. 80 | // Sega used to assign these codes (leading to the T-series numbers) but of course 81 | // they don't anymore, so pick a four letter abbreviation that identifies you and 82 | // is unlikely to clash. 83 | // The release date is the four-digit year and a three-letter month abbreviation. 84 | // Just take the first three letters of the month's name and make them uppercase. 85 | // 86 | db "(C)SEGA 1992.NOV" //Sonic 2's example! 87 | // "1234567890123456" 88 | 89 | 90 | // GAME TITLE (DOMESTIC AND OVERSEAS) 91 | // (48 Bytes ASCII String, Use Spaces For Unused Bytes) 92 | // 93 | // The game's name. Usually in all uppercase, pad the field with spaces. 94 | // There are two title fields, to account for the fact that games may change name 95 | // during localization. If you just keep the name the same everywhere then use it in 96 | // both fields. 97 | // 98 | db "GAME TITLE " //Domestic title 99 | db "GAME TITLE " //Overseas title 100 | // "123456789012345678901234567890123456789012345678" 101 | 102 | 103 | // SERIAL NUMBER 104 | // (14 Bytes ASCII String, Use Spaces For Unused Bytes) 105 | // 106 | // A field with the format "XX YYYYYYYY-ZZ", where: 107 | // "XX" | Software type 108 | // "YYYYYYYY" | Serial number 109 | // "ZZ" | Revision 110 | // 111 | // The software type indicates what kind of software is in the cartridge (usually "GM", for game). 112 | // The full list of known types so far is: 113 | // "GM" | Game 114 | // "AI" | Aid 115 | // "OS" | Boot ROM (TMSS) 116 | // "BR" | Boot ROM (Sega CD) 117 | // 118 | // The serial number is an identifier unique to the game that used to be assigned 119 | // by Sega. Try to pick something that's unlikely to clash (maybe something using 120 | // the publisher code from the copyright field to make it even more unlikely) and stick to it. 121 | // The revision is a two-digit number indicating which release of the game is this. 122 | // The initial release is "00", the first patch is "01", next one is "02", etc. 123 | // 124 | db "GM 00001051-00" 125 | // "12345678901234" 126 | 127 | 128 | // ROM CHECKSUM 129 | // (2 Bytes) 130 | // A 16-bit value that holds a checksum. Some games check the ROM to see if the checksum 131 | // matches, and some emulators may also do it and complain if the checksum is bad, but 132 | // otherwise it does nothing. 133 | // You can compute the checksum by adding up every 16-bit word from address $000200 up to 134 | // the end of the ROM (keep only the lower bits). 135 | // 136 | dw $0000 //Put the checksum here 137 | 138 | 139 | //DEVICE SUPORT 140 | // (16 Bytes ASCII String, Use Spaces For Unused Bytes) 141 | // 142 | // A list of devices or other features the game supports. One letter per device, the 143 | // unused space is filled in with spaces. It's usually "J" (3 button controller) 144 | // or "J6" (3 and 6 button controllers). 145 | // Note that 6-button controllers only need to be added to the list if the game actually 146 | // makes uses of the extra buttons. Do not add it to simply indicate that the game will 147 | // work with those controllers. 148 | // 149 | // The full list is this: 150 | // "J" | 3-button controller 151 | // "6" | 6-button controller 152 | // "0" | Master System controller 153 | // "A" | Analog joystick 154 | // "4" | Multitap 155 | // "G" | Lightgun 156 | // "L" | Activator 157 | // "M" | Mouse 158 | // "B" | Trackball 159 | // "T" | Tablet 160 | // "V" | Paddde 161 | // "K" | Keyboard or keypad 162 | // "R" | RS-232 163 | // "P" | Printer 164 | // "C" | CD-ROM (Sega CD) 165 | // "F" | Floppy drive 166 | // "D" | Download? 167 | // 168 | db "J " 169 | // "1234567890123456" 170 | 171 | 172 | // ROM ADDRESS RANGE 173 | // (8 Bytes) 174 | // 175 | // Two 32-bit values, indicating the address range covered by the cartridge. The first 176 | // value is always $000000, while the last value is usually the ROM size minus one 177 | // (unless you're using a mapper, then use the last address the console will see). 178 | // Some common ROM sizes you may see: 179 | // $07FFFF | 512KB 180 | // $0FFFFF | 1MB 181 | // $1FFFFF | 2MB 182 | // $3FFFFF | 4MB 183 | // 184 | dd $00000000 // Start 185 | dd $1fffffff // End 186 | 187 | 188 | //RAM ADDRESS RANGE 189 | // (8 Bytes) 190 | // 191 | // Two 32-bit values, indicating where RAM starts and ends. In the case of the 192 | // Mega Drive, they should be always $FF0000 and $FFFFFF. 193 | // 194 | dd $00ff0000 // Start 195 | dd $00ffffff // End 196 | 197 | 198 | // EXTRA MEMORY 199 | // (12 Bytes) 200 | // 201 | // This field indicates if there's extra memory (e.g. for saving progress, or simply 202 | // extra RAM to toy with). The contents of this field depends on what's in the cartridge. 203 | // If the game doesn't have extra memory, fill it with spaces. 204 | // If the game does have extra RAM, the field is as follows: 205 | // 2 bytes | Always "RA" 206 | // 1 byte | RAM type 207 | // 1 byte | Always $20 208 | // 4 bytes | Start address 209 | // 4 bytes | End address 210 | // 211 | // The RAM type is used to indicate whether the data is saved when turning off the 212 | // console and what kind of accesses (byte or word) are allowed: 213 | // 214 | // Type | Saves? | Usage 215 | // -----|--------|----------------------- 216 | // $A0 | No | 16-bit 217 | // $B0 | No | 8-bit (even addresses) 218 | // $B8 | No | 8-bit (odd addresses) 219 | // $E0 | Yes | 16-bit 220 | // $F0 | Yes | 8-bit (even addresses) 221 | // $F8 | Yes | 8-bit (odd addresses) 222 | // 223 | // Extra memory NOT present: // Uncomment if needed 224 | // db " " 225 | // "123456789012" 226 | // 227 | // SRAM Present: 228 | db "RA" 229 | db $f8 // SRAM Type 230 | db $20 231 | dd $00200001 // SRAM Start Address 232 | dd $0020ffff // SRAM End Address 233 | // 234 | // Eprom Present: // Uncomment if needed 235 | // db "RA" 236 | // db $e8 // Eprom Type 237 | // db $20 238 | // dd $00200001 // Eprom Start Address 239 | // dd $00200001 // Eprom End Address 240 | 241 | 242 | // MODEM SUPPORT 243 | // (12 Bytes ASCII String, Use Spaces For Unused Bytes) 244 | // 245 | // If the modem is not supported, pad with spaces. 246 | // 247 | db " " 248 | // "123456789012" 249 | 250 | 251 | //RESERVED SPACE 252 | // (40 Bytes ASCII String, filled with spaces) 253 | db " " 254 | // "1234567890123456789012345678901234567890 255 | 256 | 257 | // REGION SUPPORT 258 | // (3 Bytes ASCII String, Use Spaces For Unused Bytes) 259 | // 260 | // A list of all the regions the game supports (one letter per region). This field 261 | // had two formats over the Mega Drive's lifespan: the original format (we'll call 262 | // it "old style") is the most well known and is one letter per region. The later 263 | // format (we'll call it "new style") uses a single character to store information 264 | // about all regions. 265 | // We recommend sticking to the original "old style" format in homebrew. 266 | // 267 | // The old style is the most well known format, it stores one letter per region. 268 | // If not all the regions are used then pad the field with spaces. The regions can 269 | // come in any order. To support all three regions just use "JUE". 270 | db "U " 271 | // "123" 272 | 273 | 274 | //RESERVED SPACE 275 | // (13 Bytes ASCII String, filled with spaces) 276 | db " " 277 | // "1234567890123 278 | -------------------------------------------------------------------------------- /megadrive/tutorials/overflow/main.asm: -------------------------------------------------------------------------------- 1 | arch md.cpu 2 | endian msb //Big Endian 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin offset 8 | base offset 9 | } 10 | 11 | include "header.megadrive.asm" // Include Header & Vector Table 12 | 13 | seek($200) 14 | nop 15 | nop 16 | 17 | move.w #$3000,d0 18 | add.w #$6000,d0 19 | 20 | move.w #$6000,d0 21 | add.w #$d000,d0 22 | 23 | move.w #$a000,d0 24 | add.w #$b000,d0 25 | 26 | move.w #$d000,d0 27 | add.w #$e000,d0 28 | 29 | -; bra - 30 | 31 | -------------------------------------------------------------------------------- /megadrive/tutorials/overflow/main/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/debuggers/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !Readme.md -------------------------------------------------------------------------------- /snes/debuggers/Readme.md: -------------------------------------------------------------------------------- 1 | ## Snes Debuggers 2 | 3 | In this folder we need to add all the emulators used for Snes projects. 4 | 5 | You need to download the last releases from the following repositories: 6 | 7 | [https://github.com/Dgdiniz/bsnes-plus](https://github.com/Dgdiniz/bsnes-plus) 8 | [https://github.com/Dgdiniz/bsnes-v086-source](https://github.com/Dgdiniz/bsnes-v086-source) 9 | 10 | After the download, extract the folders to have the following folders: 11 | 12 | - bsnes-plus 13 | - bsnes_v086-source 14 | - bsnes_v086-64bit 15 | 16 | The build scripts will look for these folders, so make sure you have the right structure. 17 | -------------------------------------------------------------------------------- /snes/projects/Readme.md: -------------------------------------------------------------------------------- 1 | ## Tools 2 | 3 | This folder contains all Snes projects. 4 | 5 | -------------------------------------------------------------------------------- /snes/tools/Readme.md: -------------------------------------------------------------------------------- 1 | ## Tools 2 | 3 | This folder contains all tools used in the Snes projects. 4 | 5 | -------------------------------------------------------------------------------- /snes/tutorials/8bits-16bits-modes/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/8bits-16bits-modes/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/8bits-16bits-modes/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/8bits-16bits-modes/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | 18 | rep #$30 //Mode full 16 bits (A, X and Y) 19 | 20 | lda #$1234 //16 bits mode, so we need a 16 bits immediate 21 | sta $0000 //Writing 2 bytes 22 | ldx $0000 //Reading 2 bytes to X 23 | ldy $0000 //Reading 2 bytes to Y 24 | lda #$0078 //8 bits immediate. What Happens? 25 | 26 | sep #$20 //8 bits mode 27 | sta $0010 //Now writes only 1 byte 28 | lda $0020 //Reads 1 byte 29 | 30 | lda #$ff //Maximum value for a byte 31 | inc //What Happens? 32 | 33 | rep #$20 //Back to 16 bits again. X and Y are already 16 bits 34 | lda #$00ff //Again 35 | inc // And now? 36 | 37 | ldx #$0000 //Cleaning X and Y 38 | ldy #$0000 39 | 40 | sep #$10 //X and Y now 8 bits 41 | ldx $0000 42 | ldy $0000 43 | ldx #$ff //Same test 44 | ldy #$ff 45 | inx 46 | iny 47 | 48 | rep #$10 49 | 50 | //Here we are full 16 bits 51 | 52 | lda #$1234 53 | xba 54 | 55 | lda #$8912 56 | xba 57 | 58 | - 59 | bra - 60 | 61 | -------------------------------------------------------------------------------- /snes/tutorials/8bits-16bits-modes/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/adc-64bits/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/adc-64bits/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/adc-64bits/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/adc-64bits/main.asm: -------------------------------------------------------------------------------- 1 | arch snes.cpu 2 | 3 | fill $200000 4 | 5 | macro seek(variable offset) { 6 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 7 | base offset 8 | } 9 | 10 | include "header.snes.asm" // Include Header & Vector Table 11 | 12 | seek($8000) 13 | clc 14 | xce 15 | nop 16 | rep #$30 17 | 18 | //64 bits addition 19 | lda #$fedc 20 | sta $0006 21 | lda #$ba98 22 | sta $0004 23 | lda #$7654 24 | sta $0002 25 | lda #$3210 26 | sta $0000 27 | 28 | lda #$0000 29 | clc 30 | lda #$ddcc 31 | adc $0000 32 | sta $0010 33 | lda #$ffee 34 | adc $0002 35 | sta $0012 36 | lda #$6655 37 | adc $0004 38 | sta $0014 39 | lda #$8877 40 | adc $0006 41 | sta $0016 42 | 43 | 44 | //64 bits addition 45 | lda #$ffff 46 | sta $0006 47 | lda #$ffff 48 | sta $0004 49 | lda #$7654 50 | sta $0002 51 | lda #$3210 52 | sta $0000 53 | 54 | lda #$0000 55 | clc 56 | lda #$ddcc 57 | adc $0000 58 | sta $0010 59 | lda #$ffee 60 | adc $0002 61 | sta $0012 62 | lda #$0000 63 | adc $0004 64 | sta $0014 65 | lda #$0000 66 | adc $0006 67 | sta $0016 68 | - 69 | bra - 70 | -------------------------------------------------------------------------------- /snes/tutorials/adc-64bits/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/adc-instructions/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/adc-instructions/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/adc-instructions/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/adc-instructions/main.asm: -------------------------------------------------------------------------------- 1 | arch snes.cpu 2 | 3 | fill $200000 4 | 5 | macro seek(variable offset) { 6 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 7 | base offset 8 | } 9 | 10 | include "header.snes.asm" // Include Header & Vector Table 11 | 12 | seek($8000) 13 | clc 14 | xce 15 | nop 16 | rep #$30 17 | 18 | //adc 19 | lda #$1000 20 | clc 21 | adc #$1234 22 | 23 | //memoria/sbc 24 | tax 25 | lda #$1000 26 | sta $0000 27 | txa 28 | sec 29 | sbc $0000 30 | 31 | //inc 32 | inc 33 | inc $0000 34 | 35 | //dec 36 | dec 37 | dec $0000 38 | 39 | //X e Y (não tem add e sbc pro X e Y) 40 | inx 41 | iny 42 | dex 43 | dey 44 | 45 | //Carry no adc 46 | lda #$0001 47 | sec 48 | adc #$0001 49 | 50 | //Carry no sbc 51 | lda #$0005 52 | clc 53 | sbc #$0001 54 | 55 | //Atuação nas flags 56 | lda #$7fff 57 | inc 58 | 59 | lda #$ffff 60 | inc 61 | 62 | lda #$1000 63 | sec 64 | sbc #$1000 65 | 66 | - 67 | bra - -------------------------------------------------------------------------------- /snes/tutorials/adc-instructions/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-1/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-1/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-1/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-1/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 18 | 19 | //Immediate 20 | lda #$2001 21 | 22 | //Accumulator 23 | asl 24 | 25 | //Immediate 26 | sep #$20 27 | lda #$55 28 | 29 | gameover: 30 | -; bra - 31 | 32 | -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-1/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-2/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-2/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-2/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-2/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 18 | 19 | //Immediate 20 | lda #$2001 21 | 22 | //Absolute 23 | sta $1000 24 | 25 | //Absolute 26 | lda.b $a000 27 | 28 | //Absolute Long 29 | sta $7e1010 30 | 31 | sep #$20 //8bits 32 | 33 | //Absolute Long 34 | lda $7e1000 35 | 36 | //Absolute 37 | sta.w $1020 38 | 39 | 40 | 41 | gameover: 42 | -; bra - 43 | 44 | seek($a000) 45 | dl $123456 46 | -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-2/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-absolute/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-absolute/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-absolute/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-absolute/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | 18 | /////////16 bits 19 | rep #$30 20 | lda #$2233 //Immediate 21 | sta $0000 //Absolute 22 | lda $a000 //Absolute 23 | lda $018000 //Absolute Long 24 | 25 | lda #$0000 //Clean A 26 | 27 | /////////8 bits 28 | sep #$20 29 | lda #$44 //Immediate 30 | sta $0000 //Absolute 31 | lda $a000 //Absolute 32 | lda $018000 //Absolute Long 33 | 34 | 35 | gameover: 36 | -; bra - 37 | 38 | seek($a000) //Bank 0 39 | data: 40 | dw $1234 41 | 42 | seek($018000) //Bank 1 43 | data_bank_01: 44 | dw $5678 45 | -------------------------------------------------------------------------------- /snes/tutorials/addressing-modes-absolute/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/bass-snes-test/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/bass-snes-test/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/bass-snes-test/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/bass-snes-test/main.asm: -------------------------------------------------------------------------------- 1 | //; vim: ft=snes_bass 2 | 3 | arch snes.cpu 4 | 5 | fill $200000 //The game has 2MB 6 | 7 | macro seek(variable offset) { 8 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 9 | base offset 10 | } 11 | 12 | include "header.snes.asm" // Include Header & Vector Table 13 | 14 | seek($8000) 15 | nop 16 | lda #$01 17 | - 18 | nop 19 | inc 20 | bra - 21 | 22 | -------------------------------------------------------------------------------- /snes/tutorials/bass-snes-test/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/branching1/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/branching1/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/branching1/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/branching1/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 18 | 19 | lda #$0001 20 | label1: 21 | clc 22 | adc #$0001 23 | bra label2 24 | -; nop 25 | nop 26 | nop 27 | jmp + 28 | label2: 29 | clc 30 | adc #$0002 31 | bra - 32 | +; clc 33 | adc #$0001 34 | jmp $8000 35 | 36 | -; bra - 37 | 38 | -------------------------------------------------------------------------------- /snes/tutorials/branching1/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/cmp/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/cmp/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/cmp/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/cmp/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 // 16bits 18 | 19 | lda #$1234 20 | sta $0000 21 | 22 | rep #$c3 23 | cmp #$1234 24 | 25 | rep #$c3 26 | cmp #$1235 27 | 28 | rep #$c3 29 | cmp #$1232 30 | 31 | rep #$c3 32 | cmp $0000 33 | 34 | sep #$20 // 8bits 35 | 36 | rep #$c3 37 | cmp #$34 38 | 39 | rep #$c3 40 | cmp $0000 41 | 42 | rep #$c3 43 | cmp $0001 44 | 45 | ldx #$1234 46 | rep #$c3 47 | cpx #$1234 48 | cpx #$1232 49 | 50 | ldy #$1234 51 | rep #$c3 52 | cpy #$1234 53 | cpy #$1232 54 | 55 | -; bra - 56 | 57 | -------------------------------------------------------------------------------- /snes/tutorials/cmp/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/data-size/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/data-size/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/data-size/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/data-size/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | 18 | sep #$30 //Mode full 16 bits (A, X and Y) 19 | lda.w #$0078 //16 bits mode, so we need a 16 bits immediate 20 | 21 | -; bra - 22 | 23 | -------------------------------------------------------------------------------- /snes/tutorials/data-size/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/endian/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/endian/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/endian/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/endian/main.asm: -------------------------------------------------------------------------------- 1 | arch snes.cpu 2 | 3 | fill $200000 4 | 5 | macro seek(variable offset) { 6 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 7 | base offset 8 | } 9 | 10 | include "header.snes.asm" // Include Header & Vector Table 11 | 12 | seek($8000) 13 | clc 14 | xce 15 | nop 16 | rep #$30 //16 bits 17 | 18 | //Gravando word e byte 19 | lda #$1234 20 | sta $0000 21 | 22 | sep #$20 //8 bits 23 | lda #$12 24 | sta $0010 25 | rep #$20 //16 bits 26 | 27 | // Lendo uma word 28 | lda #$0000 29 | lda $0000 30 | 31 | lda #$0002 32 | sta $0020 33 | sep #$20 //8 bits 34 | lda $0020 35 | rep #$20 //16 bits 36 | 37 | // Acessando um endereço de 3 bytes 38 | lda #$beef 39 | sta $0050 40 | lda #$0050 41 | sta $0000 42 | lda #$007e 43 | sta $0002 44 | lda [$00] 45 | 46 | - 47 | bra - 48 | -------------------------------------------------------------------------------- /snes/tutorials/endian/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/ifelse/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/ifelse/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/ifelse/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/ifelse/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | constant varEnergyPtr = $7f1000 14 | 15 | seek($8000) 16 | clc 17 | xce 18 | nop 19 | rep #$30 20 | 21 | lda #$0008 22 | sta varEnergyPtr 23 | 24 | gameloop: 25 | lda varEnergyPtr 26 | 27 | //////// if ///////////////////////// 28 | cmp #5 29 | bne next_if1 30 | //play caution sound 31 | nop 32 | nop 33 | next_if1: 34 | ///////////////////////////////////// 35 | 36 | nop 37 | 38 | //////// if-else //////////////////// 39 | cmp #3 40 | bpl _else 41 | //draw red screen 42 | nop 43 | nop 44 | bra next_if2 45 | _else: 46 | //draw blue screen 47 | nop 48 | nop 49 | next_if2: 50 | ///////////////////////////////////// 51 | 52 | nop 53 | 54 | //////// if-else //////////////////// 55 | cmp #0 56 | beq gameover 57 | 58 | //Else, decrement energy 59 | dec 60 | sta varEnergyPtr 61 | bra gameloop 62 | 63 | gameover: 64 | -; bra - 65 | 66 | -------------------------------------------------------------------------------- /snes/tutorials/ifelse/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/loop-for/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/loop-for/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/loop-for/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/loop-for/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 18 | 19 | lda #$0000 20 | 21 | loop_for: 22 | cmp #5 23 | bpl + 24 | nop 25 | nop 26 | nop 27 | inc 28 | bra loop_for 29 | 30 | +; nop 31 | 32 | gameover: 33 | -; bra - 34 | 35 | -------------------------------------------------------------------------------- /snes/tutorials/loop-for/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/loop-while/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/loop-while/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/loop-while/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/loop-while/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 18 | 19 | lda #$0005 20 | 21 | // Normal while ////////////// 22 | while: 23 | cmp #0 24 | beq + 25 | nop 26 | dec 27 | nop 28 | bra while 29 | ////////////////////////////// 30 | 31 | +; nop 32 | 33 | lda #$0005 34 | 35 | // do/while ////////////////// 36 | dowhile: 37 | nop 38 | dec 39 | nop 40 | cmp #0 41 | bne dowhile 42 | ////////////////////////////// 43 | 44 | nop 45 | 46 | gameover: 47 | -; bra - 48 | 49 | -------------------------------------------------------------------------------- /snes/tutorials/loop-while/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/move-instructions/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/move-instructions/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/move-instructions/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/move-instructions/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | rep #$30 18 | 19 | //Load and Store 20 | lda #$0001 21 | lda #$abcd 22 | sta $0000 23 | sta $7e0010 24 | ldx #$1234 25 | ldy $0010 26 | stx $0020 27 | sty $0028 28 | stz $0010 29 | 30 | //Transfer 31 | tax 32 | txy 33 | ldy #$bbbb 34 | tya 35 | txa 36 | tya 37 | lda #$0100 38 | tcd 39 | lda #$ffff 40 | tdc 41 | 42 | //Stack 43 | lda #$1111 44 | ldx #$2222 45 | ldy #$3333 46 | pha 47 | phx 48 | phy 49 | plx 50 | pla 51 | ply 52 | 53 | - 54 | bra - 55 | 56 | -------------------------------------------------------------------------------- /snes/tutorials/move-instructions/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/overflow/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/overflow/build-v086.bat: -------------------------------------------------------------------------------- 1 | bass -o main.sfc/main.sfc main.asm 2 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/overflow/header.snes.asm: -------------------------------------------------------------------------------- 1 | //============= 2 | // SNES Header 3 | //============= 4 | seek($FFC0) 5 | // PROGRAM TITLE (21 Byte ASCII String, Use Spaces For Unused Bytes) 6 | db "Program Name Here " 7 | // "123456789012345678901" 8 | 9 | // ROM MODE/SPEED (Bits 7-4 = Speed, Bits 3-0 = Map Mode) 10 | db $20 11 | // ||___________________Map Mode: 12 | // | $X0 = LoROM/32K Banks (Mode 20) 13 | // | $X1 = HiROM/64K Banks (Mode 21) 14 | // | $X2 = LoROM/32K Banks + S-DD1 (Mode 22 Mappable) 15 | // Speed: $X3 = LoROM/32K Banks + SA-1 (Mode 23 Mappable) 16 | // $2X = SlowROM (200ns) $X5 = HiROM/64K Banks (Mode 25 ExHiROM) 17 | // $3X = FastROM (120ns) $XA = HiROM/64K Banks + SPC7110 (Mode 2A Mappable) 18 | 19 | // ROM TYPE (Bits 7-4 = Co-processor, Bits 3-0 = Type) 20 | db $00 21 | // ||___________________Type: 22 | // | $00 = ROM 23 | // | $01 = ROM+RAM 24 | // Co-processor: $02 = ROM+RAM+Battery 25 | // $0X = DSP $X3 = ROM+Co-processor 26 | // $1X = GSU $X4 = ROM+Co-processor+RAM 27 | // $2X = OBC1 $X5 = ROM+Co-processor+RAM+Battery 28 | // $3X = SA-1 $X6 = ROM+Co-processor+Battery 29 | // $4X = S-DD1 $X9 = ROM+Co-processor+RAM+Battery+RTC-4513 30 | // $5X = S-RTC $XA = ROM+Co-processor+RAM+Battery+Overclocked 31 | 32 | // ROM SIZE (Values are rounded-up for carts with 10,12,20,24 Mbits) 33 | db $01 34 | // $01 = 1 Bank = 32Kb (0.25 Mbit), $07 = 7 Banks = 224Kb (1.75 Mbit) 35 | // $02 = 2 Banks = 64Kb (0.50 Mbit), $08 = 8 Banks = 256Kb (2.00 Mbit) 36 | // $03 = 3 Banks = 96Kb (0.75 Mbit), $09 = 16 Banks = 512Kb (4.00 Mbit) 37 | // $04 = 4 Banks = 128Kb (1.00 Mbit), $0A = 32 Banks = 1024Kb (8.00 Mbit) 38 | // $05 = 5 Banks = 160Kb (1.25 Mbit), $0B = 64 Banks = 2048Kb (16.00 Mbit) 39 | // $06 = 6 Banks = 192Kb (1.50 Mbit), $0C = 128 Banks = 4096Kb (32.00 Mbit) 40 | 41 | // RAM SIZE 42 | db $00 43 | // $00 = None, $04 = 16Kb 44 | // $01 = 2Kb, $05 = 32Kb 45 | // $02 = 4Kb, $06 = 64Kb 46 | // $03 = 8Kb, $07 = 128Kb 47 | 48 | // COUNTRY/VIDEO REFRESH (NTSC/PAL-M = 60 Hz, PAL/SECAM = 50 Hz) 49 | db $00 50 | // $00 = (J)apan (NTSC), $09 = (D)Germany, Austria, Switz (PAL) 51 | // $01 = (E)USA, Canada (NTSC), $0A = (I)taly (PAL) 52 | // $02 = Euro(P)e (PAL), $0B = (C)hina, Hong Kong (PAL) 53 | // $03 = S(W)eden, Scandinavia (PAL), $0C = Indonesia (PAL) 54 | // $04 = Finland (PAL), $0D = South (K)orea (NTSC) 55 | // $05 = Denmark (PAL), $0E = (A)Common (ANY) 56 | // $06 = (F)rance (SECAM), $0F = Ca(N)ada (NTSC) 57 | // $07 = (H)olland (PAL), $10 = (B)razil (PAL-M) 58 | // $08 = (S)pain (PAL), $11 = (U)Australia (PAL) 59 | 60 | // DEVELOPER ID CODE 61 | db $00 62 | // $00 = None 63 | // $01 = Nintendo 64 | // $33 = New (Uses Extended Header) 65 | 66 | // ROM VERSION NUMBER 67 | db $00 68 | // $00 = 1.00, $01 = 1.01 69 | 70 | // COMPLEMENT CHECK 71 | db "CC" 72 | // CHECKSUM 73 | db "CS" 74 | 75 | // NATIVE VECTOR (65C816 Mode) 76 | dw $0000 // RESERVED 77 | dw $0000 // RESERVED 78 | dw $0000 // COP VECTOR (COP Opcode) 79 | dw $0000 // BRK VECTOR (BRK Opcode) 80 | dw $0000 // ABORT VECTOR (Unused) 81 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 82 | dw $0000 // RESET VECTOR (Unused) 83 | dw $0000 // IRQ VECTOR (H/V-Timer/External Interrupt) 84 | 85 | // EMU VECTOR (6502 Mode) 86 | dw $0000 // RESERVED 87 | dw $0000 // RESERVED 88 | dw $0000 // COP VECTOR (COP Opcode) 89 | dw $0000 // BRK VECTOR (Unused) 90 | dw $0000 // ABORT VECTOR (Unused) 91 | dw $0000 // NMI VECTOR (V-Blank Interrupt) 92 | dw $8000 // RESET VECTOR (CPU is always in 6502 mode on RESET) 93 | dw $0000 // IRQ/BRK VECTOR 94 | -------------------------------------------------------------------------------- /snes/tutorials/overflow/main.asm: -------------------------------------------------------------------------------- 1 | // vim: ft=snes 2 | arch snes.cpu 3 | 4 | fill $200000 5 | 6 | macro seek(variable offset) { 7 | origin ((offset & $7F0000) >> 1) | (offset & $7FFF) 8 | base offset 9 | } 10 | 11 | include "header.snes.asm" // Include Header & Vector Table 12 | 13 | seek($8000) 14 | clc 15 | xce 16 | nop 17 | 18 | rep #$30 //Mode full 16 bits (A, X and Y) 19 | 20 | lda.w #$3000 21 | clc 22 | adc.w #$6000 //Overflow 23 | 24 | lda.w #$6000 25 | clc 26 | adc.w #$d000 //No overflow 27 | 28 | lda.w #$a000 29 | clc 30 | adc.w #$b000 //Overflow 31 | 32 | lda.w #$d000 33 | clc 34 | adc.w #$e000 //No Overflow 35 | 36 | -; bra - 37 | 38 | -------------------------------------------------------------------------------- /snes/tutorials/overflow/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /snes/tutorials/simpsons/build-bsnes-plus.bat: -------------------------------------------------------------------------------- 1 | ..\..\debuggers\bsnes-plus\bsnes\out\bsnes.exe main.sfc/main.sfc -------------------------------------------------------------------------------- /snes/tutorials/simpsons/build-v086.bat: -------------------------------------------------------------------------------- 1 | ..\..\debuggers\bsnes_v086-source\bsnes\out\laevateinn.exe main.sfc/ -------------------------------------------------------------------------------- /snes/tutorials/simpsons/main.sfc/.gitignore: -------------------------------------------------------------------------------- 1 | debug/ -------------------------------------------------------------------------------- /snes/tutorials/simpsons/main.sfc/main.sfc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dgdiniz/retro-level-programming/bbd9d91df5e128ee1844d54b100061543800a817/snes/tutorials/simpsons/main.sfc/main.sfc -------------------------------------------------------------------------------- /tools/Readme.md: -------------------------------------------------------------------------------- 1 | ## Tools 2 | 3 | This folder contains global tools used in the projects for the various systems. 4 | 5 | --------------------------------------------------------------------------------