├── N64MipsDevHowto ├── n64.bib └── n64.lyx ├── Patents ├── US20010016517.pdf ├── US6239810.High_performance_low_cost_video_game_sys.pdf └── US6331856.Video_game_system_with_coprocessor_provi.pdf ├── README.md ├── cart └── oscill.html ├── cd64 ├── cd64_misc ├── cd64_protocols ├── comms_link └── ppa_workings ├── controller └── lablecckpt1.pdf ├── lockout ├── n64importmod.txt ├── n64pifmod.html └── n64securitychipmodmm6.jpg ├── mips ├── 007-2489-001.pdf ├── 007-2597-001.pdf ├── 007-2816-004.pdf ├── 007-2816-005.pdf ├── Errata R4000-R4400 Microprocessor users manual 2nd edition.pdf ├── MIPS-N32-ABI-Handbook.pdf ├── R4300_datasheet.Rev0.3.pdf ├── R4300i_Prod_Ov.ps.gz ├── U10116EJ6V0DS00.pdf ├── U10116EJ7V0DS00.pdf ├── mips-isa.pdf ├── tutorial │ ├── InstructionSets3.PDF │ ├── data.pdf │ └── mips_instructions.pdf └── vr4300.html ├── misc ├── Nintendo_64_Game_Console-BPT.pdf ├── bootcode_start_addresses.txt ├── eeprom.txt ├── mipscheck.manpage.html ├── n64_dma_pathways.dia ├── n64dox-0.5.txt ├── n64dox.txt ├── n64info.txt └── trainer.txt ├── n64ops ├── controll.txt ├── n64ops#a.txt ├── n64ops#b.txt ├── n64ops#c.txt ├── n64ops#d.txt ├── n64ops#e.txt ├── n64ops#f.txt ├── n64ops#g.txt ├── n64ops#h.txt ├── rcp.txt ├── readme.txt └── sound.txt ├── rambus └── n64_rdram_datasheet.pdf ├── rcp └── ucode_example.html ├── tutorial ├── day1n64.htm ├── day2n64.htm ├── day3n64.htm ├── day4n64.htm ├── day5n64.htm ├── day6n64.htm ├── day7n64.htm ├── day8n64.htm ├── day9n64.htm └── n64asm.htm └── z64 ├── z64_arch.txt ├── z64hw_dextrose.html ├── z64hw_dextrose_1.html └── z64hw_dextrose_2.html /N64MipsDevHowto/n64.bib: -------------------------------------------------------------------------------- 1 | % This file was created with JabRef 2.3.1. 2 | % Encoding: ANSI_X3.4-1968 3 | 4 | @OTHER{beyond3d-forum, 5 | owner = {underwoo}, 6 | timestamp = {2009.04.27} 7 | } 8 | 9 | @comment{jabref-meta: selector_publisher:} 10 | 11 | @comment{jabref-meta: selector_author:} 12 | 13 | @comment{jabref-meta: selector_journal:} 14 | 15 | @comment{jabref-meta: selector_keywords:} 16 | 17 | -------------------------------------------------------------------------------- /Patents/US20010016517.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64dev/docs/4ec56c9554e30df9c49bfdac5497bc7b4e4455d2/Patents/US20010016517.pdf -------------------------------------------------------------------------------- /Patents/US6239810.High_performance_low_cost_video_game_sys.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64dev/docs/4ec56c9554e30df9c49bfdac5497bc7b4e4455d2/Patents/US6239810.High_performance_low_cost_video_game_sys.pdf -------------------------------------------------------------------------------- /Patents/US6331856.Video_game_system_with_coprocessor_provi.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64dev/docs/4ec56c9554e30df9c49bfdac5497bc7b4e4455d2/Patents/US6331856.Video_game_system_with_coprocessor_provi.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | n64docs 2 | ============================ 3 | If you're looking for docs on the N64... congrats, you're at the right place. Sadly, 4 | nobody cared to clean this pile of junk up, so if you want something you'll have to 5 | wade through all the cruft. 6 | 7 | Ideally, this will all wind up in a more organized form on the website, but "ain't 8 | nobody got time for that". 9 | -------------------------------------------------------------------------------- /cart/oscill.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
11 |
12 |
13 |
14 |
15 | Search 16 | Projects 17 |
19 | 20 | 21 | 23 | 28 | 29 | 30 | 32 | Vita 33 | 34 | 35 | ![]() 37 | Last Updated: 2000.02.03 38 | © 2000 Alexander Reeder 39 | Access #1068 40 | 41 | 42 | 43 | |
44 |
45 |
46 |
47 | ![]() 49 | 55 |
206 | ![]() 208 | 210 | |
|
43 | 44 | l33t import mod 46 |for PAL and NTSC consoles 48 |you might wonder what an
50 | "import mod" is,basically,it's an
the mod works like
99 | this:
to switch all lines at once 149 | (theres no relais in the diagram coz i was too lazy,but u 150 | know how to wire them lines up ;) 151 |so you can decide if the n64 153 | uses the pins of the pal or the ntsc pif. 154 |the pink pins on the pcbs are
156 | not connected. btw,since your pal n64 is not 162 | working anymore,you can send it to nintendo of europe 163 |and tell them to fix it,it 165 | isnt expensive. 166 |
|
180 |
![]() |
45 |
|
63 | |||
![]() |
68 | ||||
![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
IRIX 6.5 » Man Pages
find in page
111 |
112 | MIPSCHECK(1) 113 | 114 | NAME 115 | 116 | mipscheck, r8kpp, r5kpp, u64check - Examines binaries for instruction 117 | sequences 118 | 119 | SYNOPSIS 120 | 121 | mipscheck [-v] [-condition[:action...] ... ] files 122 | 123 | r8kpp [-v] [-condition[:action...] ... ] files 124 | 125 | r5kpp [-v] [-condition[:action...] ... ] files 126 | 127 | u64check [-v] [-condition[:action...] ... ] files 128 | 129 | DESCRIPTION 130 | 131 | mipscheck examines binaries for instruction sequences that may have 132 | processor specific behavior. It reports which conditions it found, 133 | and in certain cases, will modify the sequence so that the binary 134 | behaves consistently on all platforms. On exit, mipscheck returns an 135 | exit status which is the number of occurrences of the specified 136 | condition(s) found. 137 | 138 | The -v option generates verbose output, including the address of each 139 | problem found. 140 | 141 | Specifying mipscheck operates on object files, archives files, 142 | executables, and DSOs. Specifying r8kpp, r5kpp, u64check are 143 | alternative ways of invoking mipscheck which imply default values 144 | designed specifically for the specified architecture. 145 | 146 | Conditions 147 | -pref[:action...] Look for and remove prefetch instructions. 148 | 149 | The pref and prefx prefetch instructions are part 150 | of the mips4 instruction set. They are fully 151 | implemented on the r10000 and the r5000 but are 152 | not supported on r8000 based machines. See the 153 | r8000 errata sheet for more details. 154 | 155 | The default actions are: - 156 | pref:check:noforce:repair 157 | 158 | -mfhilo[:action...] Look for instructions that reference the HI or LO 159 | registers and are one or two instructions after a 160 | mfhi or mflo instruction. 161 | 162 | The mips1, mips2, and mips3 instruction sets 163 | specify that there is a two instruction hazard 164 | between a mflo instruction and a following 165 | instruction that references the LO register. This 166 | hazard was removed from the mips4 instruction set 167 | (that is, it was up to the processor to supply the 168 | hardware interlock). The r8000 and the r10000 169 | have this hardware interlock but the r5000 does 170 | not; this requires the compiler to continue to 171 | enforce the scheduling hazard. 172 | 173 | It is possible that Irix 6.1 64bit binaries may 174 | have this relaxed instruction scheduling sequence. 175 | As of Irix 6.2, all SGI compilers generate code 176 | that does not depend upon the processor handling 177 | the hardware interlock, but rather the compilers 178 | schedule the instructions to avoid it. See the 179 | r5000 errata sheet for more details. 180 | 181 | The default actions are: - 182 | mfhilo:check:noforce:norepair 183 | 184 | -cvtl[:action...] Look for cvt.s.l and cvt.d.l instructions. These 185 | instructions convert 64-bit integers to single or 186 | double floating point format. 187 | 188 | Revision [1.1] of the r5000 can misexecute cvt.s.l 189 | and cvt.d.l instructions when the 64-bit integer 190 | input data is in either of the following ranges: 191 | 192 | 0x7FF0 0000 0000 0000 to 0x7FFF FFFF FFFF FFFF 193 | 0x8000 0000 0000 0000 to 0x800F FFFF FFFF FFFF 194 | 195 | When input data is in the preceding ranges, these 196 | instructions are supposed to trap into the kernel 197 | where they will be emulated in software. 198 | Unfortunately, they do not trap and they generate 199 | an incorrect result. These instructions are 200 | fairly rare and are found in mips3 and mips4 201 | executables only; they are never in mips1 or mips2 202 | programs. There is a work-around for this 203 | problem, implemented entirely within the operating 204 | system kernel, which should be invisible to all 205 | user programs. See the r5000 errata sheet for 206 | more details. 207 | 208 | The default actions are: - 209 | cvtl:check:noforce:norepair 210 | 211 | -fmulmul[:action] Look for a floating point multiply immediately 212 | followed by a floating point or integer multiply. 213 | 214 | Very early versions of the r4300 (used only in the 215 | Nintendo Ultra64 Game Player) could mis-execute 216 | the second multiply instruction when the first 217 | multiply encountered a NaN or an Infinity operand. 218 | See the r4300 errata sheet for more details. 219 | 220 | The default actions are: - 221 | fmulmul:check:noforce:norepair 222 | 223 | -idivmul[:action] Look for integer divides and multiplies in 224 | branch-delay slots or preceding a branch-target. 225 | 226 | On the r10000, under extremely rare conditions, if 227 | an integer multiply or integer divide is 228 | interrupted, the EPC (Exception Program Counter) 229 | will point to the instruction following the 230 | multiply/divide and the HI register will not be 231 | updated. There is a work-around for this problem 232 | implemented entirely within the operating system 233 | kernel, which should be invisible to all user 234 | programs. See the r10000 errata sheet for more 235 | details. 236 | 237 | The default actions are: - 238 | idivmul:check:noforce:norepair 239 | 240 | Actions 241 | Each condition has an optional colon (:) separated list of actions 242 | associated with it. action can be any of the following: 243 | 244 | check Check for the specified condition (default action). 245 | 246 | nocheck Do not check for the specified condition. 247 | 248 | force Examine the instruction sections for the condition even 249 | if mipscheck has other means of determining that the 250 | condition does not exist. For example, an instruction 251 | sequence involving mips4 instructions could not exist 252 | in a mips3 executable. force instructs mipscheck to 253 | search for the condition anyway. 254 | 255 | noforce Do not examine the instruction sequences unless 256 | necessary (default action). 257 | 258 | repair Modify the instruction sequence so that it does not hit 259 | the specified condition. This action is valid only 260 | with the -pref condition. 261 | 262 | norepair Do not modify the code (default action). 263 | 264 | If a condition is specified with no actions, mipscheck assumes the 265 | default actions. For example, specifying -mfhilo is equivalent to 266 | -mfhilo:check:noforce:norepair. 267 | 268 | Unexpected Behaviors 269 | The -fmulmul option may give a false positive in the case of a 270 | floating point multiply instruction in a branch delay slot. The 271 | mipscheck program does not look at the target of the branch and so 272 | must assume that the branch target may be another multiply 273 | instruction. 274 | 275 | The -pref:force option will almost always give false positives because 276 | it will report on every prefetch instruction found instead of just the 277 | combinations of prefetches that can lead to mis-execution on an r8000. 278 | 279 | Because mipscheck cannot examine input data for data-dependent 280 | problems, it must report on instruction sequences that may fail under 281 | the proper conditions. For example, mipscheck will report all cvt.d.l 282 | instructions, not just the ones that may get bad input data. 283 | 284 | Similarly, because mipscheck cannot know about tlb-miss and cache-miss 285 | behavior, it must report on instruction sequences that might trigger 286 | the r4000 branch-at-end-of-page problem even though the actual 287 | conditions required to hit it are quite rare. 288 | 289 | NOTES 290 | 291 | "Is this anything to be concerned about?" is a valid question. In 292 | general, the answer is no. But SGI developers and some customers who 293 | have access to early revisions of systems may need this tool to help 294 | identify and/or repair problems. The following are some relevant 295 | cases: 296 | 297 | 1. Irix 6.1 binaries compiled with -n32 -mips4 that are moved to an 298 | r5000 system should be checked with r5kpp. There should be no such 299 | binaries in the field; but because experimental systems and 300 | experimental compilers were available, it is possible that such 301 | binaries exist. 302 | 303 | 2. The Irix 6.2 (and later) operating systems for r8000s will 304 | automatically patch any running program to remove the prefetch 305 | instructions. This will not affect the performance on an r8000 but 306 | it will avoid the r8000 prefetch problem. In rare cases, the 307 | kernel will not be able to avoid the problem and will request that 308 | the user run the binary through r8kpp to execute the repair 309 | permanently. 310 | 311 | 3. Ultra64 game developers should always run u64check to locate cases 312 | where their assembly code violates the game player's hardware 313 | restrictions. 314 | 315 | 4. Irix 6.2 binaries compiled using -mips3 or -mips4, using 64-bit 316 | integers, and running on Revision [1.1] of the r5000 may, in rare 317 | cases, encounter the cvtl problem. The kernel handles this case 318 | but incurs a small overhead for checking on this condition. The 319 | overhead should be negligible. If r5kpp finds no problem in an 320 | executable, it will mark the executable as "clean", which helps the 321 | kernel eliminate the overhead. 322 | 323 | 5. On all MIPS processors, when an instruction is interrupted, the EPC 324 | (Exception Program Counter) points to the interrupted instruction. 325 | The exception to that rule is when the interrupted instruction is 326 | in a branch-delay slot, in which case the EPC points to the 327 | previous branch instruction. On an r10000, if the kernel ever 328 | detects a "bad" EPC for an interrupted integer multiply or integer 329 | divide, the kernel will silently (and at no measurable performance 330 | cost) repair the EPC and the damaged HI register. If the 331 | interrupted instruction is in a branch-delay slot of an 332 | unconditional branch, the kernel may not be able to repair the EPC 333 | and will abort the program, reporting the result in the SYSLOG. 334 | 335 | To make it easier for the kernel to detect and repair the EPC in these 336 | cases, the compiler will not put an integer multiply or divide in a 337 | branch delay slot of an unconditional branch, nor will it make the 338 | following instruction a branch target. Versions 6.2 through 7.2 of 339 | the SGI compilers occasionally break these rules when generating code 340 | -mips4. This is not a problem but it makes it more difficult for the 341 | kernel to detect and repair the problem. Compiler versions 7.2.1 and 342 | later always obey these two rules. 343 | 344 | EXIT CODES 345 | 346 | mipscheck terminates with an exit code set to the number of conditions 347 | found. For example, if it found 10 -mfhilo problems, it would 348 | terminate with an exit code of 10. In the case of r8kpp, this may be 349 | a little misleading because the command has not only found each of the 350 | problem conditions but it has repaired them as well. If you were to 351 | run r8kpp on the binary a second time, no conditions would be reported 352 | because the binary has been patched. 353 | 354 | EXAMPLES 355 | 356 | The following example shows how to build a mips4 binary and verify 357 | that there are no prefetch instructions: 358 | 359 | % cc -mips4 -n32 -o bean bean.c 360 | % mipscheck -pref:check:norepair bean 361 | % echo $status 362 | 363 | The following example shows how to compile a file to be linked into an 364 | Ultra64 Game program and verify that there are no dangerous multiply 365 | pairs: 366 | 367 | % cc -mips2 -32 -c bean.c 368 | % mipscheck -fmulmul:check:norepair bean.o 369 | % echo $status 370 | 371 | This example examines the location of the cvtl problem(s) in the 372 | /bin/sh program. 373 | 374 | % mipscheck -v -cvtl:check:norepair:force /bin/sh 375 | mipscheck [1.6] 376 | /bin/sh: r5000 cvt.d.l cvt.s.l problem at 0x100138d0 377 | cvtl found : 1 378 | 379 | By invoking r8kpp, you are specifying that all r8000 specific 380 | conditions should be checked for and repaired. This is equivalent to 381 | specifying the following: 382 | 383 | % mipscheck -pref:check:noforce:repair myprog 384 | 385 | By invoking r5kpp, you are specifying that all r5000 specific 386 | conditions should be checked for and reported. This is equivalent to 387 | specifying the following: 388 | 389 | % mipscheck -mfhilo:check:noforce:norepair \ 390 | -cvtl:check:noforce:repair myprog 391 | 392 | By invoking u64check, you are specifying that all r4300 specific 393 | conditions should be checked for and reported. This is equivalent to 394 | specifying the following: 395 | 396 | % mipscheck -fmulmul:check:noforce:norepair myprog 397 | 398 | FILES 399 | 400 | /usr/sbin/mipscheck mipscheck executable 401 | 402 | /usr/sbin/r8kpp Symbolic link to /usr/sbin/mipscheck 403 | 404 | /usr/sbin/r5kpp Symbolic link to /usr/sbin/mipscheck 405 | 406 | /usr/sbin/u64check Symbolic link to /usr/sbin/mipscheck 407 | 408 | SEE ALSO 409 | 410 | elfdump(1) 411 | 412 | http://www.mips.com for information on chips. 413 | 414 | 415 | 416 |417 | 418 | 419 |
8 | 9 | 10 | 11 |12 |
14 | First, there are several assemblers you could use for the N64, the one I've had 15 | the most luck using is ASMN6432.EXE from the PSY-Q devkit. Unfortunately, I can't tell 16 | you where to get the devkit (which does contain a C compiler, so if you're not macho enough 17 | to use assembler, you can go right ahead and use those illegal libs!), because many people 18 | would object to it. It's simple enough to find with a search on Google, I regularly loose 19 | the URL and then find it again in about 30 min. with Google. LEARN THE WAYS OF THE GOOGLE! 20 | 21 | The other assemblers that I've had some success with are the one by HalleysCometSoftware 22 | and Anarko's assembler (in that order). You can get HCS's assembler (and good demo code) from the link above. 23 | Anarko's assembler is on Dextrose. 24 | 25 | I recommend creating a directory like C:\n64asm\ , so that it has no spaces and you can just 26 | keep everything in there. Each one of these assemblers needs a different style command to assemble, 27 | they are: (On the DOS/CMD command-line) 28 | 29 | For ASMN6432.EXE: 30 | asmn6432 /p SOURCE,OUTPUTFILE.BIN 31 | copy HEADER /B+OUTPUTFILE.BIN OUTPUTFILE.N64 32 | 33 | For n64asm.exe (Anarko's): 34 | Look at the demo sources for the header puesdo-codes, and type n64asm by itself 35 | on the command-line for how to assemble. 36 | 37 | For n64.exe (HCS's): 38 | n64 SOURCE.ASM -r 39 | 40 | You may have noticed that ASMN6432 needs an extra command that adds the rom header, you can get 41 | that from HCS's zip file. 42 | 43 | Second, I must say that what I know about the N64 (everything I know at a certain time 44 | that can be applied toward a certain working code file will be eventually described in a "Day"), 45 | which isn't much as I write this, came from reading documents found on Dextrose and the web AND 46 | from HCS kindly putting up with my endless questions on Dextrose's Forum, this (hopefully to be 47 | these) document(hopefully (s)) would not have been possible without his help. 48 | 49 |114 | 115 | -------------------------------------------------------------------------------- /tutorial/day2n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |Our First ROM
50 | From here on out, I assume you are using ASMN6432, but N64.exe (HCS's assembler) has 51 | almost the same syntax and, now that I think of it, Anarko's assembler is still quite similar, you'll just have 52 | to figure out how to use each one (and maybe tinker the code a little to get it to assemble on 53 | your chosen assembler. 54 | 55 | Here's our first code file: 56 | 57 | ;;---START OF CODE FILE---;; 58 | org $80000400 59 | 60 | li t1,8 61 | lui t0,$bfc0 62 | sw t1,$07fc(t0) 63 | 64 | infin: 65 | nop 66 | j infin 67 | ;;---END OF CODE FILE---;; 68 | 69 | Now to see what each line does: 70 | 71 | org $80000400 72 | 73 | This tells the assembler where the entry point of the code is in N64 memory ($80000400 is standard for ASM progs). 74 | 75 | li t1,8 76 | lui t0,$bfc0 77 | sw t1,$07fc(t0) 78 | 79 | These lines (which I got from HCS), stop the N64 from crashing in 5 secs. after your 80 | program starts (according to HCS, and some other people). I'm not going to explain 81 | them until later (because I don't what about them stops the N64 from crashing). 82 | 83 | infin: 84 | 85 | If you don't know what that is, I suggest you go read either the GBA or NES assembly sections (the 86 | GBA one is better written in my opinion). Here's a link for you. 87 | 88 | nop 89 | 90 | A Classic, it does nothing, that's right, nothing, except that you should put NOPs 91 | after labels, a spot appearantly known as a "Delay Slot", some assemblers get pissed off 92 | if you have anything but a NOP in the Delay Slot. 93 | 94 | j infin 95 | 96 | J is the jump instruction, J jumps to a label, like Goto in BASIC. In this case, J jumps to 97 | infin, creating an infinite loop like while(1); . 98 | 99 | Assemble your file like shown in the beginning, if you get no errors, you've done a good job. 100 | (I recommend (again) that you keep your assembler and code files in C:\n64asm\, and CD to that 101 | directory in DOS, when you want to assemble something) 102 | 103 |This Day In Review
104 | 105 | Tomorrow, we'll download an emulator and a plugin needed for the type of programming 106 | where using. Hopefully, we'll quickly get to setting up our VI (Video Interface) registers. 107 | 108 | Until Next Time, 109 | -Mike H a.k.a GbaGuy 110 | 111 |Intro - Day 2 112 | 113 |
8 | 9 | 10 | 11 |12 |
14 | In the other tutorials, I may have sort of taught the assembly language 15 | and the system workings at the same time. I don't think that would be best this 16 | time around because of the N64 being somewhat more complex. So today, I'll just 17 | describe the registers and the instructions: LI,LA,LW,SW. 18 | 19 |76 | 77 | -------------------------------------------------------------------------------- /tutorial/day3n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |Before We Get Started
20 | You're probably wondering how to run your ROM. Well, Nemu (which you can get from Zophar) 21 | has a pretty good debugger. To run the ROMs that we'll eventually get to making, you need this 22 | Plugin for Nemu to support the bitmap-mode 23 | drawing that we'll be doing (Thanks again to HCS, for pointing me to it). 24 | 25 |The R4300i
26 | The main processor that will be running all of our code for a while is a standard RISC MIPS R4300i, 27 | similar to the one in the PS1 (identical maybe?). It runs at ~93MHz. This thing has even more registers 28 | than the ARM7 in the GBA!! There are 32 registers, I'm still not positive what they all are for, but they are 29 | (in the order listed in Nemu's debugger): 30 | 31 | R0 - Special in that it is always zero, you can't change it. 32 | AT - Not entirely sure. Seems to be available to us. 33 | V0-V1 - Don't know. 34 | A0-A3 - Are used to pass parameters to subroutines. 35 | T0-T7 - Temporary data registers, what we should use for regular coding. 36 | S0-S7 - Called "Save" or "Saved" registers, preserved across subroutine calls?? 37 | T8-T9 - Don't know, maybe same as other 'T' registers. 38 | K0-K1 - No Clue. 39 | GP - No Clue. 40 | SP - See AT 41 | S8 - No Clue. 42 | RA - Stores the Return Address for subroutine calls. 43 | 44 | If someone can email me and fill me in on the ones that I don't know or anything that's wrong that you 45 | ever see, please correct me. (I suppose I'll look at the MIPS tech docs and fill out the rest of the list) 46 | 47 |The LI,LA Instructions
48 | First, the LI instruction. The LI instruction takes 2 operands (parameters): 49 | 50 | li t0, 2 ; the register on the left will get the number on the right. 51 | 52 | simple enough. 53 | 54 | Now, the LA instruction. It also takes 2 operands: 55 | 56 | la t4, LABEL ; the register on the left will get the address of the label on the right. 57 | 58 | Easy, but there's another use. You can (have to with HCS's assembler) use it the same as LI also, 59 | so like this: 60 | 61 | la t0,2 ; register/left gets number/right 62 | 63 | Wow, that was way easier and shorter to explain than I thought it was going to be... (Did I miss something?) 64 | 65 |This Day In Review
66 | 67 | Hopefully tomorrow, we'll take a look at the Video Interface Mem. Registers. 68 | Nintendo seems to like memory mapping their initialization interfaces... 69 | 70 | Happy Learning!, 71 | - GbaGuy 72 | 73 |Intro - Day 3 74 | 75 |
8 | 9 | 10 | 11 |12 |
14 | The VI (Video Interface) Memory Mapped Registers start at 0xA4400000 in N64 main memory 15 | and allow you to initialize the bitmapped screen in many different ways (See Anarko's N64OPS on Dextrose. 16 | Anarko's document lists them starting at 0x04400000, I don't know why. The Video Registers are: 17 | (As listed by Nemu's debugger): 18 | 19 | VI_STATUS_REG (0xA4400000) - Chooses color-depth, and some gamma/antialias/interlacing options 20 | VI_DRAM_ADDR_REG (0xA4400004) - The address of the currect framebuffer (set it to the memory you're going to 21 | use for the N64's bitmapped screen.) 22 | VI_H_WIDTH_REG (0xA4400008) - The Horizontal Resolution of the framebuffer. 23 | VI_V_INTR_REG (0xA440000C) - Not sure. Check out N64OPS. 24 | VI_V_CURRENT_LINE_REG (0xA4400010) - I think it gives the current line that is being drawn. (use it to check 25 | for VBlank??) 26 | VI_TIMING_REG (0xA4400014) - Not sure what it means that N64OPS says.. 27 | VI_V_SYNC_REG (0xA4400018) - "number of half-lines per field", what the **** does that mean? 28 | VI_H_SYNC_REG (0xA440001C) - Don't know. See N64OPS. 29 | VI_H_SYNC_LEAP_REG (0xA4400020) - Don't know. See N64OPS. 30 | VI_H_VIDEO_REG (0xA4400024) - Ditto. 31 | VI_V_VIDEO_REG (0xA4400028) - Ditto. 32 | VI_V_BURST_REG (0xA440002C) - Ditto. 33 | VI_X_SCALE_REG (0xA4400030) - Seems obvious, but description is a little wierd, commonly seen at 0x200. 34 | VI_Y_SCALE_REG (0xA4400034) - Seems obvious, but description is a little wierd, commonly seen at 0x400. 35 | 36 | I'll fill out this chart as I figure out exactly what each one does. See Anarko's N64OPS for his 37 | description (which come almost straight from the comments from the official dev headers). 38 | 39 | If anyone has some more info on these, please email me (I'm going to be saying that alot, aren't I? :) ) 40 | 41 |118 | 119 | -------------------------------------------------------------------------------- /tutorial/day4n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |Before We Get Started
42 | You're probably wondering how to run your ROM. Well, Nemu (which you can get from Zophar) 43 | has a pretty good debugger. To run the ROMs that we'll eventually get to making, you need this 44 | Plugin for Nemu to support the bitmap-mode 45 | drawing that we'll be doing (Thanks again to HCS, for pointing me to it). 46 | 47 |Initialization of Video
48 | But first, there's 2 instructions we still need to learn: LW and SW. They work like so: 49 | 50 | LW Loads a 32-bit Word from memory like this: 51 | lw t1,0(t3) ; the 32-bit word at the address created by the memory location 52 | ; in t3 + zero in this case, will be put into t1. 53 | Here's another: 54 | lw t0,4(t1) ; the 32bit word at the address created by the memory location in t1 +4 will be put into 55 | ; t0. So if the address 0xA0200004 has 32 in it, 56 | ; and t1 has 0xA0200000 in it plus the 4 will be 0xA0200004 and then t0 will end up with 57 | ; the 32. 58 | 59 | I hope you understood that. 60 | 61 | SW works in precisely the same way except that it will store the register on the left into the memory address 62 | created by the register plus offset on the right. (The 4 and the zero in the examples are the offsets.) 63 | 64 | Here's our video initialization code: 65 | ;;---CODE START---;; 66 | ; I should mention that while I use 0x in this tutorial's text for hexadecimal numbers, 67 | ; ASMN6432.exe uses $. 68 | la t0,$A4400000 ; VI status register (start of VI reg. mem.) 69 | li t1, $103002 ; basically 16bit color and some other things 70 | sw t1,0(t0) 71 | la t1,0xa0200000 ; address of screen bitmap (framebuffer) 72 | sw t1,4(t0) 73 | li t1,320 ; width of screen (horizontal resolution?) 74 | sw t1,8(t0) 75 | li t1,$2 ; Don't know. 76 | sw t1,12(t0) 77 | li t1,$0 ; Ditto. 78 | sw t1,16(t0) 79 | li t1,$3e52239 ; Ditto until next comment 80 | sw t1,20(t0) 81 | li t1,$0000020d 82 | sw t1,24(t0) 83 | li t1,$00000c15 84 | sw t1,28(t0) 85 | li t1,$0c150c15 86 | sw t1,32(t0) 87 | li t1,$006c02ec 88 | sw t1,36(t0) 89 | li t1,$002501ff 90 | sw t1,40(t0) 91 | li t1,$000e0204 92 | sw t1,44(t0) 93 | li t1,$200 ; something about horizontal scaling? 94 | sw t1,48(t0) 95 | li t1,$400 ; something about vertical scaling? 96 | sw t1,52(t0) 97 | ;;---CODE END---;; 98 | 99 | It basically selects a 320x240 16 bit mode, and does some other stuff I don't know yet. 100 | (That code is essentailly the same as code that HCS was again, nice enough to show me, so 101 | now I use 320x240 16 bit mode.) 102 | It probably wouldn't be too hard to change that to 32 bit color, but I just don't feel like 103 | it (I think you'd have to change $103002 to $103003) and 16 bit color is plenty for most things. 104 | The offsets are not permanently added to the register in ()s, so in the code, the offsets just keep 105 | gaining by 4, for each VI register set. 106 | 107 |This Day In Review
108 | 109 | Tomorrow, we'll learn some math instructions and then the next day, we'll do some loops. 110 | Then, we'll put together a code file that clears the screen (with code that, yep, HCS showed me.) 111 | 112 | Hold on! We're getting there!, 113 | - GBAGuy 114 | 115 |Intro - Day 4 116 | 117 |
8 | 9 | 10 | 11 |12 |
14 | Today is going to be all about the math instructions ADD and SUB. 15 | 16 |90 | 91 | -------------------------------------------------------------------------------- /tutorial/day5n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |The ADD Instruction
17 | Now, reel in the fish slowly! Oops, ADD means ADDition, not Attension Deficit Disorder! 18 | What was I thinking!. 19 | 20 | Ok, now that the bad joke is out of the way, ADD works like this: 21 | ADD t1,t2,t3 ; t1 = t2 + t3; is just about the simplest way I can describe it. 22 | 23 | I've also seen: 24 | ADD t1, 2 ; which is supposed to be t1 += 2, appearantly. THIS DOESN'T ALWAYS WORK! 25 | ; alot of the time, an assembler either errors or interprets this as t1 += V0 26 | 27 | Which brings me to another point, a register's (in some assemblers) number can be used 28 | instead it it's t1,v0,a3 style name. See Nemu's debugger for as far as I know, is the correct order. 29 | 30 |The SUB Instruction
31 | INSERT BAD JOKE ABOUT SubWay HERE. 32 | 33 | The SUB Instruction works like so: 34 | SUB t0,t4,t5 ; t0 = t4 - t5; There's a chance I might have t4 and t5 in the wrong order, 35 | ; but I think I have it right. 36 | 37 | The "I've also seen" comment applies to SUB as well. 38 | 39 |The MUL/DIV Instruction
40 | The MUL and DIV Instructions work like this (as far as I can tell): 41 | 42 | MUL t0,t2,t4 ; t0 = t2 * t4; 43 | 44 | DIV t1,t0,t6 ; t1 = t0 / t6; 45 | 46 | Also note that all these math instructions use signed numbers. 47 | 48 |Comparison/Branch Instructions
49 | This would have been shorter than I wanted it to be, so I'll have to talk about Comparison/Branch Instructions 50 | also. 51 | 52 | The first instruction we'll learn is BNEZ, BNEZ is a psuedo-instruction that only Anarko's assembler doesn't 53 | support (along with LA). BNEZ is used like so: 54 | 55 | bnez t1, LABEL ; IF t1 not equal zero THEN GOTO LABEL 56 | 57 | For assemblers that don't support it, use: 58 | 59 | bne t1,$0,LABEL ; same as above, note that $0 is the special CPU register that is permanently zero. 60 | 61 | The other use for BNE (no Z) is: 62 | 63 | bne t1,t3,LABEL ; IF t1 not equal t3 THEN GOTO LABEL 64 | 65 | There is also: 66 | 67 | beq t1,t3,LABEL ; IF t1 == t3 THEN GOTO LABEL 68 | 69 | blt t0,t1,LABEL ; IF t0 less than t1 THEN GOTO LABEL 70 | 71 | bgt t0,t1,LABEL ; IF t0 greater then t1 THEN GOTO LABEL 72 | 73 | ble t2,t4,LABEL ; IF t2 less or = to t4 THEN GOTO LABEL 74 | 75 | bge t2,t4,LABEL ; IF t2 greater or = to t4 THEN GOTO LABEL 76 | 77 | Add a U to the end of the instruction (like BGEU) to compare unsigned numbers. 78 | 79 |This Day In Review
80 | 81 | Tomorrow, we'll either learn another set of instructions, or we'll do 82 | something else (maybe a pic on screen)! 83 | 84 | Until Next Time!, 85 | - Mike H a.k.a GbaGuy 86 | 87 |Intro - Day 5 88 | 89 |
8 | 9 | 10 | 11 |12 |
14 | Today is going to be short (maybe) and be about subroutines. 15 | The N64 CPU's subroutine call instruction is JAL (Jump And Link) it works 16 | like so: 17 | 18 | JAL LABEL ; jump to LABEL, putting return address in ra. 19 | NOP ; you should put a NOP after JALs also. Delay Slot? 20 | 21 | Then at LABEL you have: 22 | 23 | LABEL: 24 | NOP ; Delay Slot NOP 25 | JR ra ; Jump Register ra (that contains return address) 26 | 27 | Note that you can't nest subroutine calls, as a subroutine call will erase 28 | the old return value in ra. The GBA is also like that, the NES is not. 29 | 30 | It would help if there was a built-in stack. (Is there?) 31 | 32 |51 | 52 | -------------------------------------------------------------------------------- /tutorial/day6n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |The LUI Instruction
33 | I'm not sure what the LUI instruction does, but I'm fairly sure 34 | that it loads the second 16bits of a register, like so: 35 | 36 | LI t1,0 ; t1 = $00000000 37 | LUI t1,$a440 ; after instruction, r1 = $a4400000 38 | 39 | Simple enough, if I didn't miss anything. 40 | 41 |This Day In Review
42 | 43 | Tomorrow, we'll definitely put a pic on the screen! 44 | 45 | I Can't Wait!, 46 | - GbaGuy 47 | 48 |Intro - Day 6 49 | 50 |
8 | 9 | 10 | 11 |12 |
14 | Today we'll put a picture on the screen. 15 | 16 |100 | 101 | -------------------------------------------------------------------------------- /tutorial/day7n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |First
17 | Make a 320x240 bitmap in MSPaint, save in C:\n64asm\ as pic.bmp. 18 | Next, goto Dextrose and download the 19 | patch to the GroundZero Devkit, what we want is the BMP2N64 program. Copy 20 | BMP2N64.exe to your n64 assembly folder. Open a DOS Prompt and type: 21 | 22 | cd your assembly folder path 23 | bmp2n64 -in:pic.bmp -out:pic -label:pic -16 24 | 25 | Two files should be created, you can delete the .H file, but keep the .S file. 26 | The .S File may work as is, but I recommend you delete the lines before 27 | the label and replace all ".half"s with "dh" (no quotes). 28 | 29 |The Code
30 | 31 | The code for this isn't that much different than we've seen before 32 | or that you could have come up with on your own. So here we go (the whole thing): 33 | 34 | ;;---CODE START---;; 35 | org $80000400 ; starting point 36 | 37 | li t1,8 ; crash protection 38 | lui t0,$bfc0 ; I still don't know what this specifically does. 39 | sw t1,$07fc(t0) 40 | 41 | la t0,$A4400000 ; start of VI regs. ; this block initializes Video 42 | li t1, $103002 43 | sw t1,0(t0) 44 | la t1,$a0200000 ; the frame buffer address 45 | sw t1,4(t0) 46 | li t1,320 47 | sw t1,8(t0) 48 | li t1,$2 49 | sw t1,12(t0) 50 | li t1,$0 51 | sw t1,16(t0) 52 | li t1,$3e52239 53 | sw t1,20(t0) 54 | li t1,$0000020d 55 | sw t1,24(t0) 56 | li t1,$00000c15 57 | sw t1,28(t0) 58 | li t1,$0c150c15 59 | sw t1,32(t0) 60 | li t1,$006c02ec 61 | sw t1,36(t0) 62 | li t1,$002501ff 63 | sw t1,40(t0) 64 | li t1,$000e0204 65 | sw t1,44(t0) 66 | li t1,$200 67 | sw t1,48(t0) 68 | li t1,$400 69 | sw t1,52(t0) 70 | 71 | li t0,0xa0200000 72 | li t3,2 73 | la t2,MKImage ; MKImage should be the label in your .S file 74 | li t1,320*240*2-2 75 | drawImage: 76 | lh t4,0(t2) 77 | sh t4,0(t0) ; there's probably a better way, but oh well :) 78 | add t2,t2,t3 79 | add t0,t0,t3 80 | sub t1,t1,t3 ; there's a better place for this that'll be discussed later 81 | bnez t1,drawImage 82 | 83 | infin: 84 | nop 85 | j infin 86 | 87 | include MKImage.S ; MKImage.S should be the filename of your .S File 88 | ;;---CODE STOP---;; 89 | 90 |This Day In Review
91 | 92 | I hope you take the time to understand code and not just rip it :)! 93 | 94 | Until Next Time!, 95 | - Mike H a.k.a GbaGuy 96 | 97 |Intro - Day 7 98 | 99 |
8 | 9 | 10 | 11 |12 |
14 | This thing is so Evil and Cool at the same time, I can't come up 15 | seem to come up with even a good joke for the intro (I said "Slot!", maybe?). 16 | 17 |64 | 65 | -------------------------------------------------------------------------------- /tutorial/day8n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |The Info
18 | This information is brought to you by HCS: 19 | 20 | The code for this isn't that much different than we've seen before 21 | or that you could have come up with on your own. So here we go (the whole thing): 22 | (It has been slightly edited)(HCS, I hope you don't mind.): 23 | 24 | This is the instruction immediately after a jump or branch instruction. It is executed during the jump (actually, while 25 | the instruction at the target is being fetched). For example, if we have 26 | 27 | code:-------------------------------------------------------------------------------- 28 | jal dest 29 | addi t0,t0,1 30 | -------------------------------------------------------------------------------- 31 | 32 | Both the jump and the addition will occur. There are some instructions which can't be in 33 | delay slots though (I don't have my manual with me right now and I don't remember what they are) 34 | and asmn64 checks for those. One good application for this is to make loops: 35 | 36 | code:-------------------------------------------------------------------------------- 37 | li t0,7 38 | loop: 39 | ; something to be done 8 times 40 | bnez t0, loop 41 | addi t0,-1 42 | -------------------------------------------------------------------------------- 43 | 44 | The increment (decrement in this case) is had for free, during time the processor would be 45 | otherwise wasting. It is important, whenever you code a jump, to put a NOP after it until 46 | you intend to use the delay slot, otherwise some other part of the code might execute 47 | accidentally. I believe that asmn64 has a command line switch to do this for you automatically. 48 | 49 | The exception to the delay slot execution is several branches called "likely". Actually, they still 50 | execute the instruction in the delay slot, but if the branch is not taken the delay instruction 51 | is skipped. This takes some extra time for the processor to ignore the instruction, so they 52 | should only be used when it is "likely" that the branch will be taken. 53 | 54 |This Day In Review
55 | 56 | It's always good to get the information from someone who knows what they're talking about! 57 | 58 | Important stuff!, 59 | - GbaGuy 60 | 61 |Intro - Day 8 62 | 63 |
8 | 9 | 10 | 11 | 12 |13 |
15 | The RSP is M-a-g-i-c-a-l! 16 | 17 | Just keep saying that to yourself any time you can't figure why your code isn't working! :) 18 | Just kidding! 19 | 20 |136 | 137 | -------------------------------------------------------------------------------- /tutorial/day9n64.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |The RSP
21 | First, read N64OPS#H.TXT (Anarko's N64OPS doc, which if you don't have by now, pretend I'm hitting 22 | you with a trout!!!) and look at the SP registers section. 23 | 24 | The RSP is like another processor and contains most of the instructions of the main R4300i. The RSP can 25 | only address main memory from 0xA4000000 To 0xA40FFFFF, if you want to access other parts of memory you 26 | have to use the SP Mem. Registers to DMA to other parts of main memory. Conveniently, the SP registers 27 | reside in the part of main memory that the RSP can access. 28 | 29 | There are two sections of the RSP's memory that are for Data and Code respectively, one is DMEM that 30 | stores Data and is at 0xA4000000 to 0xA4000FFF (small :( ). The other is IMEM and stores code for the RSP 31 | to execute and is at 0xA4001000 to 0xA4001FFF. 32 | 33 |The SP Registers
34 | The RSP Memory registers start at 0xA4040000 and are: 35 | (These aren't in order and are only the ones that we are going to need today.) 36 | 37 | SP_MEM_ADDR_REG (0xA4040000) - Location to DMEM or IMEM to write to, commonly zero. Bit 12 selects 38 | (1) IMEM or (0) DMEM. 39 | So to transfer to/from starting at 0 write 0x1000 for IMEM or 0x0 for DMEM 40 | to this register. 41 | 42 | SP_DRAM_ADDR_REG (0xA4040004) - Location in main memory to DMA to/from. 43 | SP_RD_LEN_REG (0xA4040008) - The length in bytes of data to read from main memory INTO the RSP. 44 | When you write to this register, DMA will start. 45 | 46 | SP_WR_LEN_REG (0xA404000C) - The length in bytes of data to read from RSP TO main memory. 47 | Writing to this register will also start DMA. 48 | 49 | SP_PC_REG (0xA4080000) - The Program Counter for the RSP, set it to 0x0 before starting the RSP. 50 | 51 | SP_STATUS_REG (0xA4040010) - Allows you to set breaks and halts and interrupts and stuff, you need to 52 | clear a bunch of that stuff in this register to start the RSP. 53 | 54 |Setting Up DMA
55 | Setting up DMA is quite simple, 3 steps: 56 | 57 | 1) Set SP_MEM_ADDR_REG. 58 | 2) Set SP_DRAM_ADDR_REG. 59 | 3) Set SP_RD_LEN_REG (SP_RD_LEN_REG is Main Mem. -> RSP) 60 | 61 | Writing to a length register causes to DMA to go. 62 | 63 |Making The RSP Go
64 | Making the RSP go is 2 steps: 65 | 66 | 1) Set SP_PC_REG (zero is just fine.) 67 | 2) Set SP_STATUS_REG (you need to clear almost everything that can be 68 | cleared in the first 9 bits (0-8) (See N64OPS#H.txt) 69 | 70 | After you clear the halts and breaks and stuff the RSP will start running it's code. 71 | 72 |The Code File
73 | Here's the code to get some code onto the RSP: 74 | 75 | ;;---CODE START---;; 76 | org $80000400 77 | 78 | li t1,8 ; that crash protection code 79 | lui t0,$bfc0 80 | sw t1,$07fc(t0) 81 | 82 | la t0,0xA4040000 ; SP_MEM_ADDR_REG 83 | li t1,0x1000 ; 0x1000 is the start of IMEM (remember as far as the RSP knows it's memory starts at zero, 84 | ; but we know it's memory really starts at 0xA4000000) 85 | sw t1,0(t0) ; SP memory address 86 | 87 | la t0,0xA4040004 ; SP_DRAM_ADDR_REG 88 | la t1,RCPCode ; address of our code to put in the RSP's IMEM. 89 | sw t1,0(t0) 90 | 91 | la t0,0xA4040008 ; SP_RD_LEN_REG 92 | li t1,72 ; length in bytes, to find this value, multiply the #lines of code that you're putting in the RSP * 8 93 | sw t1,0(t0) ; the DMA will start after this write is done. 94 | 95 | nop 96 | nop ;time for the emulator, I'll leave making a loop to wait until DMA is done an exercise to you (my kind reader.) 97 | 98 | la t0,0xA4080000 ; SP_PC_REG 99 | la t1,0x0 ; just set it to zero 100 | sw t1,0(t0) 101 | 102 | la t0,0xA4040010 ; SP_STATUS_REG 103 | li t1,%100101101 ; clears a bunch of things like halt and break. (See N64OPS#H.txt) 104 | sw t1,0(t0) ; and makes the code run 105 | 106 | infin: 107 | nop 108 | j infin 109 | nop 110 | 111 | RCPCode: 112 | obj 0x0 ; sets the base of the code so that jumps/branches will be correct. 113 | always: 114 | nop 115 | j always 116 | objend ; not sure if it's endobj on some assemblers... 117 | nop 118 | nop 119 | nop 120 | ;;---CODE END---;; 121 | 122 | I realize that the code doesn't do anything, I just wanted to get code onto the RSP. 123 | To verify that it works, take a look at Nemu's debugger under "Commands" and under the RSP tab, 124 | you should see just an infinite loop (a J instruction to the address above it). 125 | 126 |This Day In Review
127 | 128 | Hopefully I'll be able to do more with the RSP and therefore teach you more as time goes on. 129 | 130 | Happy coding!, 131 | - GbaGuy 132 | 133 |Intro - Day 9 134 | 135 |
8 | 9 | 10 | 11 | 12 |13 |
15 | The Serial Interface (a.k.a The SI Registers) is used for many things including reading controller 16 | data and writing to mempaks and using the Rumble. I recommend that you see LaC's hardware doc for the best 17 | info on using the SI. 18 | 19 |96 | 97 | -------------------------------------------------------------------------------- /tutorial/n64asm.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |The Info
20 | The SI does DMA with a 64 byte command packet between PIH RAM and main memory (PIH RAM is in main 21 | memory, but it's like taboo to use normal writes with it...). The 64b command packet can be visualized like 22 | this (all diagrams adapted/copied from LaC's doc): 23 | 24 | [64byte block] at 0xbfc007c0 (1fc007c0) 25 | { Command : Results placed here when you DMA the data back to main memory 26 | ff 00 00 00 : 00 00 00 00 - 8 bytes 27 | ff 00 00 00 : 00 00 00 00 - 8 bytes 28 | ff 00 00 00 : 00 00 00 00 - 8 bytes 29 | ff 00 00 00 : 00 00 00 00 - 8 bytes 30 | ff 00 00 00 : 00 00 00 00 - 8 bytes 31 | ff 00 00 00 : 00 00 00 00 - 8 bytes 32 | ff 00 00 00 : 00 00 00 00 - 8 bytes 33 | ff 00 00 00 : 00 00 00 01 - 8 bytes 34 | } ^^pif status/control byte 35 | 36 | It will help for our purposes that the last byte, refered to by LaC as the control byte, always be 01. 37 | Although there's room for 4 bytes, most commands only use 3, so put the Reset command ($FF) in the first spot 38 | to align everything so you get the Results conveniently 4 byte aligned. 39 | 40 | This diagram describes the form of the 3 bytes of the command: 41 | 42 | Command Types: 43 | 44 | | Command | Description |t |r | 45 | +---------+--------------------------+-----+ 46 | | 00 | request info (status) |01|03| 47 | | 01 | read button values |01|04| 48 | | 02 | read from mempack slot |03|21| 49 | | 03 | write to mempack slot |23|01| 50 | | 04 | read eeprom |02|08| 51 | | 05 | write eeprom |10|01| 52 | | ff | reset |01|03| 53 | NOTE: values are in hex 54 | t r Command 55 | Every command is in the form of (referring to the diagram): t r Command. So reading a controller is 0xFF010401 (that 56 | first 0xFF is the alignment thing from the first diagram.). The only thing that I understand how to do so far is read 57 | the controllers, the command packet for reading the controllers looks like this: 58 | 59 | [64byte block] 60 | { command data 61 | ff 010401 - ffffffff 62 | ff 010401 - ffffffff 63 | ff 010401 - ffffffff 64 | ff 010401 - ffffffff 65 | fe 000000 - 00000000 66 | 00 000000 - 00000000 67 | 00 000000 - 00000000 68 | 00 000000 - 00000001 69 | } 70 | 71 | The byte 0xFE means that there aren't any more commands, it can be left off if the packet is totally full of commands. 72 | Appearantly, the controller that we are reading changes by 1 with each controller read command, so the first one is 73 | controller 1, then #2,#3,and #4. Also, if you just read 1 controller, the reading resets between sending command packets, 74 | so you can't read each controller 1 at a time with 1 read command in each packet (I don't know why you'd do that, but you 75 | can't anyway...). 76 | 77 | Note that some commands aren't only 3 bytes long, that's because of the real meaning of t and r. t is how many bytes 78 | we are sending in this specific command not including the r byte (but including, appearantly, the Command byte that 79 | comes after r ). r is how many bytes we want returned as Results from the PIH. Also note that having more than 3 80 | bytes in the specific command makes the previous type of diagram out of alignment with where the results are going to 81 | end up. Results will always end up after the specific command, they just might not be perfectly aligned on those 4 82 | bytes... 83 | 84 |This Day In Review
85 | 86 | Most (more like all) of this information was edited from LaC's hardware document v0.8. 87 | Please note that this was just to explain SI (or atleast how I understand it, might not be correct.) and 88 | doing specific things like reading controllers and making the RumblePak go will be covered in separate "Day"s. 89 | 90 | Read The Docs!, 91 | - GBAGuy 92 | 93 |Intro - Day 10 94 | 95 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /z64/z64_arch.txt: -------------------------------------------------------------------------------- 1 | The Z64 contains an ALi chip, which is far more than a 386: it is a 2 | more or less complete PC (memory, dma and timers, isa bus, keyboard 3 | and simple ISA-based IDE) with that chip, a clock generator and a few 4 | of DRAM chip you have a completely running system. 5 | The N64 interface is done (in HW1.x and 2.x) with a QuickLogic PLD, 6 | while in the 3.x hardware is implemented on-dice in the CPU (which ALi 7 | is able to customize up to a certain degree...) The "ROM" memory and 8 | the emulation interface is visible to the Z64 as a set of I/O ports. 9 | 10 | The Z64 has 512k of RAM (upgradable to 1Meg soldering in the 11 | appropriate chip) and 512K of flash memory (this memory is paged). 12 | it works at ~28MHz. The "ROM" is a 5V dual-bank EDO SIMM. A non-edo or 3.3V 13 | (5v tolerant) part WON'T work. 14 | 15 | the layout of the flash is as follows: 16 | 17 | 4k of "boot rom": the rom is structured as a ISA-EXTENSION bios (which 18 | makes the rest of the flash a bootable disk) 19 | 20 | 444k of a virtual drive (the Z64 sees this as 'A:') formatted as a 21 | normal MSDOS FAT12 floppy. 22 | 23 | 64k in which the bios for the x86 is stored two times. 24 | 25 | The Z64 uses Caldera's OpenDOS as operating system, but it works just 26 | fine with any MSDOS-Like OS (for example the EXCELLENT RxDOS, which 27 | became totally free recently). 28 | 29 | The internal bios is limited to CHS addressing for the hard drive, so 30 | you could have an hard disk of no more than 5xx megabytes, but OpenDOS 31 | has an even harder limitation: the rom'able version only supports 32 | 512 bytes (1 sector) clusters, so you can have only 32 megs as 33 | harddrive. This limitation is bypassed by the IOMega GUEST.EXE so it 34 | is possible to use a zip disk -- most probably using the GUEST.EXE of 35 | the 250M zip it should work fine. 36 | 37 | The Z64 user interface is a simple MSDOS program (the on-screen N64 38 | gui is done by sending to the N64 a special "ROM") 39 | 40 | The Flash-Rom in HW2 is a SST 28SF040 41 | On the SST site (http://www.ssti.com/) this chip is well documented. 42 | It's unlikely that software can fry this chip, but it can get in a non-accessible state. 43 | On the above site you can find instructions to exit this state. 44 | 45 | The CDROM is not a problem related to bios or cluster size: in fact 46 | the "cdrom.sys" driver and MSCDEX.EXE do handle all the accesses to 47 | the CD directly (the "cdrom.sys" generally hits the hardware directly 48 | exposing a known interface via a device for MSCDEX.EXE, which hooks 49 | itself to the int vectors and ADDS functionality to the existing BIOS 50 | and DOS). The problem is the Z64.EXE program, which makes certain 51 | assumptions regarding the environment in which he lives: first off the 52 | drive containing the roms must be writeable -- try to protect the zip 53 | with the zip tools on the pc -- second it assumes to detect 54 | insertion/removal of the disk using the ASPI interface (directly 55 | addressing a "ZIP 100" device. If these requirements are not met it 56 | behaves somewhat weirdly (don't understand why it still works with 57 | 250M zip, but it does, oddly enough) 58 | 59 | 60 | --------------------------------------------------------------------------------8 | This tutorial is about coding for the Nintendo 64 using 9 | your chosen assembler (see Day 1). The tutorial assumes basic assembly 10 | knowledge, so you would most likely want to come here after knowing GBA 11 | or NES assembly. 12 | 13 | The Extreme Basics (all I know :) )
14 | Day 1 - Figuring Out the Assembler 15 | Day 2 - Some Instructions 16 | Day 3 - Video Interface Registers 17 | Day 4 - Math 18 | Day 5 - Subroutines 19 | Day 6 - See Screen, See Pic On Screen 20 | Day 7 - The Delay Slot 21 | Day 8 - Getting Code onto The RSP 22 | Day 9 - Using The Serial Interface 23 | 50 | 51 |
52 | 53 | If anyone would like to donate something, such as an N64 or V64 54 | , please EMail Me. Also, don't 55 | hesitate to send comments or suggestions. 56 | 57 |If you came directly here, check out all the GBA and NES stuff
on the Home Page! 58 |