User Tools

Site Tools


notes:comporg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
notes:comporg [2019/05/09 10:10]
jwilli57 [Boss Breaker]
notes:comporg [2020/02/11 09:28] (current)
hshare [Useful Links]
Line 1: Line 1:
-======COMPORG COURSE NOTES======+======Computer Organization Course Notes Page======
  
-{{  :​notes:​asm.jpg ​ |}} +=====Course Notes Wiki===== 
- +----
-======Course Notes Wiki======+
 This is a space for members of the Computer Organization class to create a source of information reflective and assisting to the course. This is a space for members of the Computer Organization class to create a source of information reflective and assisting to the course.
  
Line 13: Line 12:
   * Questions you have that may deserve a more visual answer   * Questions you have that may deserve a more visual answer
  
-======NES ROMs====== +=====Helpful Things===== 
- +----       
-  * [[http://​lab46.g7n.org/​~wedge/​content/​NES/​brainstorm.html|Play BrainStorm]],​ by [[/​journal/​spring2019/​relliot9/​start|Rana Elliott]] (<​relliot9@corning-cc.edu>) and [[/​journal/​spring2019/​mkowulic/​start|Mike Kowulich]] (<​mkowulic@corning-cc.edu>​) +      NOP or nopno operationtakes two exact cycles ​to execute,simplest ​  ​way ​to "​wait"​ 
-  * [[http://​lab46.g7n.org/​~wedge/​content/​NES/​bossbreaker.html|Play BossBreaker]],​ by [[/​journal/​spring2019/​jwilli57/​start|"​jimito"​ Williams]] (<​jwilli57@corning-cc.edu>​) +       
-  * [[http://​lab46.g7n.org/​~wedge/​content/​NES/​portalkombat.html|Play PortalKombat]],​ by [[/​journal/​spring2019/​sepp/​start|Stephen Epp]] (<​sepp@corning-cc.edu>) +      ; ​Comment Symbol ​ 
-  * [[http://​lab46.g7n.org/​~wedge/​content/​NES/​asteroids.html|Play Asteroids]],​ by [[/​journal/​spring2019/​dgreen16/​start|Dylan Green]] (<​dgreen16@corning-cc.edu>) and [[/​journal/​spring2019/​wprice2/​start|William Price]] (<​wprice2@corning-cc.edu>​) +       
- +      ​SEG Segment,  
-Want to play the NES ROMs on your own system? You can download them [[https://​lab46.g7n.org/​~wedge/​content/​NES_ROMs|here]] +       
- +      ​ORG ​Basically int main()Starting place goes after 
-For web-based playI am using [[https://​jsnes.org/​|jsNES]],​ a javascript NES emulator. +       
-=====Useful links===== +      ​lda ​Load Accumulator Register ​(ldload (a) Accumulator 
- +             ​# Means Immediate 
-  * http://​blog.fritzvd.com/​2016/​06/​13/​Getting-started-with-NES-programming/​ +             ​-  
-  * Tim Cheeseman Blog Posts +       
-    * https://​timcheeseman.com/​nesdev/​2016/​01/​18/​hello-world-part-one.html +      ​sta ​Takes value in accumulator and stores ​in some memory (st) store (a) accumulator ​register ​-> address 
-    * https://​timcheeseman.com/​nesdev/​2016/​01/​22/​hello-world-part-two.html +       
-    * https://​timcheeseman.com/​nesdev/​2016/​02/​06/​color-in-motion.html +      ​inx ​(in) increment ​(x) X register 
-    * https://​timcheeseman.com/​nesdev/​2016/​02/​22/​sprites-and-input.html +       
-  * A useful introduction ​to NES hardwarebut a bit lengthy. +      ​jmp ​- Jump, unconditionally snaps to a point  
-    * https://​www.youtube.com/​watch?​v=XwGj1ciSAtw +       
-  * Mednafen Help +      ​brX ​- A conditional jump (bzbranch if zero (beqbranch if equal 
-    * https://​www.fantasyanime.com/​emuhelp/​mednafen +       
-  * This sends you to a nice page discussing Object Attribute Memory for a sprite. +       
-    * http://​wiki.nesdev.com/​w/​index.php/​PPU_OAM +       
-  * https://​nesdoug.com/​ +      ​% - Binary value 
-  * https://​games.greggman.com/​game/​programming_m_c__kids/​ +      ​$ - Hex Value 
-  * http://​nintendoage.com/​forum/​messageview.cfm?​catid=22&​threadid=7155 +       
-    * NES programming broken into weekly lessons.  +       
-  * http://​www.dustmop.io/​blog/​2015/​04/​28/​nes-graphics-part-1/​ +=====Address Ranges===== 
-  * http://​www.dustmop.io/​blog/​2015/​04/​28/​nes-graphics-part-1/​ +---- 
-    * A good intro/​overview of the NES tile graphics, how they'​re stored, how to access them, and color palettes +      ​$0000 ​$007F TIA Registers 
-  * 6502 assembly +      ​$0080 ​$00FF RAM 
-    * http://​nintendoage.com/​pub/​faq/​NA/​index.html?​load=nerdy_nights_out.html +      ​$0200 ​$02FF RIOT registers 
-      ​* http://​nintendoage.com/​forum/​messageview.cfm?​catid=22&​threadid=4147 +      ​$1000 ​$1FFF ROM 
-      ​* https://​web.archive.org/​web/​20140612092301/​http://​www.obelisk.demon.co.uk/​6502/​ +       
-  * https://​en.wikibooks.org/​wiki/​NES_Programming +=====Useful Links===== 
-  * https://​jarrodparkes.com/​2014/​01/​20/​nes-attribute-tables/​ +----
-  * http://​wiki.nesdev.com/​w/​index.php/​NES_reference_guide +
-  * https://​wiki.nesdev.com/​w/​index.php/​Programming_guide +
-  * http://​blog.fritzvd.com/​2016/​06/​13/​Getting-started-with-NES-programming/​ +
-  * http://​www.geocities.jp/​yy_6502/​yychr/​0yychr.html +
-    * YYCHR downloadworks with wine on the pod +
-  * NES Sprites: +
-    * https://​nesdoug.com/​2018/​09/​05/​06-sprites/ +
-  *http://​gendev.spritesmind.net/​page-collide.html +
-    *Useful guide to basic collision detection schemesusable for multiple sprites +
-    * https://​mednafen.github.io/​documentation/​debugger.html +
-  * https://​www.datacrystal.romhacking.net/​wiki/​Super_Mario_Bros.:​RAM_map +
-    * https://​www.romhacking.net/​forum/​index.php?​topic=25371.0 +
-  * https://​shiru.untergrund.net/​articles/​programming_nes_games_in_c.htm +
-  * https://​megacatstudios.com/​blogs/​press/​creating-nes-graphics +
-  * https://​www.nutsvolts.com/​magazine/​article/​using-seven-segment-displays-part-2 ​(Practical Decoder/​Driver ICS) +
-  * https://​easyeda.com/​modules/​5611BH_e4b1d99de0464446949d4933562b1710 ​(seven-segment display) +
-  * https://​megacatstudios.com/​blogs/​press/​organizing-nes-graphics-banks +
-  * NES ROM analysis videos +
-    * [[https://​www.youtube.com/​watch?​v=2VHySu_jaPw|SMB3 sound fx bug]] +
-    * [[https://​www.youtube.com/​watch?​v=wfrNnwJrujw|SMB3 loading seam]] +
- +
-====January 22, 2019==== +
- +
-Back in the day, there used to be giant computers, and the reason these things were so huge, is because the switches that ran the logic were about the size of light switches, and you need around ​million of those in a computer. Therefore, big switches equals big computer. People (from AT&Teventually discovered a way to make these switches smaller and more reliable through the use of transistors. These didn't require the actual flipping up and down like a light switch, so they could last longer. That is how we got computers we can put on our laps!  +
- +
-For our project this upcoming semester, we will need to have a significant understanding on how the NES does what it does. Firstly, we'll need to understand the language "6502 assembly",​ which the NES understands. For the video portion of our experiments,​ we'll be using 8x8 images as well as only having the selection of 3 colors. Be careful with the background of the program, it may be more difficult applying color than it is with sprites. As for sound, FamiTracker is a good recommendation for 8-bit music that will work well with our plans. +
- +
-====January 29th, 2019==== +
-Definitions:​ +
- +
-cpp c preprocessor that does general analysis of code and makes substitutions for intermediary between the coder and the computer. +
- +
-mednafen: +
- +
-  * At the moment, mednafen needs an additional command "​rm ​-rf ~/​.mednafen"​ before the actual call of mednafen +
-  * speaking of, mednafen loads up differently from nestopia as mednafen requires the nes file that is meant to be loaded ​in addition to the command to start mednafen +
-  * alt-d for the debugger ​in game +
-  * alt-shift-1 to input controller buttons for player 1 (for second player, type a 2 instead of a 1) +
- +
-nes:  +
- +
-  * hardware: can read 32 kB cartridge ROM at a time +
- +
-Interrupts:​ +
-  * an interrupt vector is an input used to get the computer'​s attention ie pressing a button +
-  * the reset.s file that we've seen is an interrupt vector itself +
- +
-==6502 Assembly Terms== +
-  * ADC - add accumulator ​with carry, adds two values +
-  * AND logical and operator +
-  * ASL - Arithmetic Shift Left, shifts all bits one to the left +
-  * BCC Branch if Carry Clear, If carry flag is clear branch to a new location +
-  * BCS - Branch if Carry Set, If carry exists, branch to a new location +
-  * BEQ - Branch if Equal, ​ if Zero flag exists, branch +
-  * BIT - Test if pits are set in a memory location +
-  * BMI - Branch if Minus, If negative flag is set, branch +
-  * BNE - Branch if Not Equal, If zero flag is clear, branch +
-  * BPL - Branch if Positive, if negative flag is clear, branch +
-  * BRK - Break (Force Interrupt), Break flag set to 1 +
-  * BVC - Branch if overflow clear, if overflow flag is clear, branch +
-  * BVS - Branch if overflow set, if overflow flag is set, branch +
-  * CLC - Clear Carry, sets carry flag to zero +
-  * CLD - Clear Decimal Mode, set decimal mode flag to 0 +
-  * CLI - Clear interrupt disable, clears the interrupt disable flag +
-  * CLV - Clear Overflow Flag, V = 0 +
-  * CMP - Compare, compares contents of accumulator to another memory value +
-    * Sets Carry flag if A >= M +
- * Sets Zero flag if A == M +
- * Sets Negative flag if bit 7 is set +
-  * CPX - Compare X Register, compares ​X register ​to memory value +
-  * CPY - Compare Y Register, compares Y register to memory value +
-  * DEC Decrement Memory, Subtracts one from the value held at mem location +
-  * DEX - Decrement X register, Subtract one from X Register +
-  * DEY - Decrement Y Register, Subtract one from Y Register +
-  * EOR - Exclusive Or +
-  * INC - Increment memory, Adds one to the memory value +
-  * INX - Increment x Register +
-  * INY - Increment Y register +
-  * JMP - Unconditional ​Jump, will always happen +
-  * JSR - Jump to Subroutine  +
-  * LDA - Load Accumulator,​ loads value from accumulator +
-  * LDX - Load X Register +
-  * LDY Load Y Register +
-  * LSR - Logical Shift Right, Bits in and M are shifter one to the right +
-    * The Zero bit is set to Carry +
-  * NOP - No Operation, No changes +
-  * ORA - Logical Inclusive Or, Inclusive Or with A and M +
-  * PHA - Push Accumulator,​ Puts a copy of the accumulator onto the stack +
-  * PHP - Push Processor Status, Puts status flags onto the stack +
-  * PLA - Pull Accumulator,​ Pulls a value from the stack into the accumulator +
-  * PLP - Pull Processor Status, Sets flags from stack values +
-  * ROL - Rotate Left, shift everything in A or M to the left +
- * Carry flag is set to bit 7 +
-    * Bit 0 is filled with the current carry flag +
-  * ROR - Rotate Right, Shift everything in A or M to the right +
- * Carry flag is set to old bit 0 +
-    * bit 7 is filled with Carry flag +
-  * RTI - Return from interrupt, at end of interrupt processing routine +
-    * Sets all flags from stack +
-  * RTS - Return from Subroutine, at the end of a subroutine, return to call +
-  * STC - Subtract with Carry, subtracts the contents of a memory to accumulator +
-  * SEC - Set Carry Flag, Set Carry flag to one +
-  * SED - Set Decimal flag, Set Decimal Flag to one +
-  * SEI - Set Interrupt Disable, Set Interrupt Disable Flag to one +
-  * STA - Store Accumulator,​ Store accumulator contents to memory +
-  * STX - Store X Register, Store X register to memory +
-  * STY - Store Y Register, Store Y register to memory +
-  * TAX - Transfer Accumulator to X, Copies Acc to X register +
-  * TAY - Transfer Accumulator to Y, Copies Acc to Y register +
-  * TSX - transfer Stack pointer to X, Copies current stack contents to X +
-  * TSA - transfer Stack pointer to Accumulator,​ Copies current stack contents to Acc +
-  * TSX - Transfer X to Stack, copies X contents into the stack +
-  * TYA - Transfer Y to Accumulator,​ Copies Y contents into the Acc +
- +
-There are three main registers used, one for doing basically anything, and two for temporarily storing information. +
- +
-====Compiling==== +
-  * cc65 -Oi filename.c --add-source +
-  * ca65 filename.s +
-  * ca65 reset.s +
-  * ld65 -C filename.cfg -o filename.nes reset.o filename.o nes.lib +
- +
-====February 7th, 2019==== +
- +
-Pseudo-random number generation:​ +
- +
-A technique for PRNG is to have the hardware cycle through thousands of randomly-generated numbers, where each call to the PRNG updates the number, with a seed initialized at the beginning of the game. Below is an example of such a function in 6502 assembly. The seed only needs to be set once, and it will always return an unsigned byte. +
- +
-<​code>​ +
-;prng.s +
- +
-;Add variable and function to Zeropage +
-.export _Prng +
-.exportzp _Seed +
- +
-.segment "​ZEROPAGE"​ +
-_Seed: .res 2 ;Equivalent of an unsigned short +
- +
-.segment "​CODE"​ +
-_Prng: +
-  ldx #8 ;Iterate 8 times +
-  lda _Seed+0 ;Load first byte of seed to alter +
-+
-  asl +
-  rol _Seed+1 +
-  bcc :+ +
-  eor #$2D ;Shift bits and XOR register value +
-+
-  dex +
-  bne :-- +
-  sta _Seed+0 ;Return first byte in seed as random number +
-  cmp #0 +
-  rts ;Return +
-</​code>​ +
- +
-To add it to the toolchain, create a header file and include it in your program, while being sure to assemble it in your Makefile. An example header file: +
- +
-<​code>​ +
-//prng.h +
- +
-#ifndef PRNG_H_ +
-#define PRNG_H_ +
- +
-#include <​stdint.h>​ +
- +
-extern uint16_t Seed; +
-#pragma zpsym("​Seed"​)+
- +
-uint8_t Prng(void)+
- +
-#endif +
-</​code>​ +
- +
-Remember to set your seed in the beginning of your program. Calls to the Prng will return a random byte, but manipulating said byte could produce a specified range of outcomes you desire. +
- +
-====February 13th, 2019==== +
- +
-PPU OAM, or Object Attribute Memory is memory inside of the PPU that can store up to 64 sprites'​ information inside 4 bytes each. The first byte, or Byte 0, is used for referring to the positioning of the top of the referred sprite in the y axis. Byte 1 is more focused on where the sprite exists on the pattern table. The bits in Byte 2 can be used to do a variety of attribute shifting to the sprite including flipping it on the x and y axis, setting the priority of the image in comparison to the background, the palette of the sprite, and much more! Byte 3 wraps things up with the x - coordinate of the left side of the sprite. To determine whether a sprite will be on top or underneath another, look at the addresses in comparison to one another. The sprite data that occurs first in OAM will be the one that appears in the front. +
- +
-====February 14th, 2019==== +
- +
-A carry is when you want to perform a mathematical operation, and the result goes above 255. The carry flag basically just says that there is an additional bit set to 1 in the stored value. This is necessary since the accumulator only holds 8-bit values. Carry flag allows you to do MOAR!!! +
- +
- +
- +
-=====Game Creation Project Guidelines===== +
- +
-  * First one can be written in assembly or C +
-  * Can be one or Two Player +
-  * Nothing more complicated than simple early games like Pac-Man +
-  * Can be done alone or in groups +
-  * Our Projects +
-    * Rana and Mike - Brain storm, zombie tower defense +
-    * Jimito - Boss Breaker: Every level is a Boss fight +
-    * Josh - Lancer: Medieval tag with pointy sticks! +
-    * Stephen - Portal Kombat: Two player Mayhem! +
-    * a +
-    * a +
-    * a +
-    * a +
- +
- +
- +
- +
-====Portal Kombat==== +
-Created by Stephen +
-This will be a primitive form of Mortal Kombat... but with portals! +
-    *TODO +
-      ​* New sprites ​ x +
-      ​* <​del>​Walls</​del>​ +
-      ​* Portals! +
-        * Build portals ​ x +
-        * Set up teleportation logic x +
-      ​* Attack +
-        * Make weapons appear and move x +
-        * Collision detection (Yippee) x +
-        * <​del>​Score</​del>​ +
-        * Life x +
-      ​* Title Screen +
-        * Choose character x +
-        * P1 & P2 x +
-      ​* End Game Stuff +
-        * Life decreasing x +
-        * FINISH HIM! x +
-      ​* Bonus stuff +
-        * Restarting x +
-        * Second level +
-        * Change the way Thing attack works (Now the Thing'​s weapon is twice as fast!!)x +
-        * Show character names when arrow is over the sprite x +
-====Boss Breaker==== +
-  * Jimito +
-  * Game concept: Every level is a Boss, Bullet-hell, Shooter  +
-  * Boss ideas +
-     -SWARM: alien mass attacks, while the boss slowly grows +
-     -Forger: fire scatters about the screen, while the forger makes an arsenal +
-     -Factory: machines make robots to defend, while boss is built +
- +
-Progess:\\  +
-Minions: Done\\  +
-Bosses: Done\\  +
-Players: Done\\  +
-Score/​Health:​ Done\\  +
-Win/Game Over: Done\\  +
-Menu: Done\\ +
-Music: DONE, just add custom song +
- +
-To-do:\\  +
-Secrets +
-Medals +
-====Brain Storm==== +
-    * Rana and Mike +
-    * concept : Plants Vs zombies style tower defense +
-    * player protects the brain from zombies trying to eat it +
-    * If zombies reach the far left of the screen the brain'​s health goes down every tick until it reaches zero lose condition +
-    * Win if successfully defending for three waves +
-    * Power Ups +
-        * heal the brain a little (Heart) +
-    * Zombies +
-        * 2x sizes to start off, little ones and boss ones +
-        * maybe different colors based on difficulty +
-    * Brain Wave +
-        * Player Projectiles,​ maybe just little ">"​s or something +
- +
-====Lancer==== +
-    *Joshua +
-    *Main concept2 players chasing each other around, trying to hit the sides/back of the other sprite until an arbitrary score is achieved +
-    *side concepts: PowerUps, multiple arenas, hazards, platformer mode (stretch goal). +
-    *Controls: 4 directional movement with the d-pad(diagonal presents problems with hit detection), sprint with the B button (1 ppf vs 3 ppf(pixels per frame) movement speed), A for powerups (displayed in upper left corner for player 1, upper right corner for player 2). +
- +
-====Asteroids by Dylan & Billy==== +
- +
-==Premise== +
- +
-Earth is being assaulted by asteroids and, as  +
-the main character, it's your duty to protect it.  +
-With your state of the art space ship and cannons,  +
-you can blow the asteroids into small bits that can  +
-burn up in Earth'​s atmosphere. +
- +
-      +
-==Mechanical Process== +
- +
-Earth is seen at the bottom of the screen  +
-with your space ship positioned directly above it. +
-Once start is pressed, the asteroids will start +
-hurdling towards Earth from the top of the screen  +
-progressively quicker and quicker. You can use the  +
-directional keys to move around, and B to shoot at  +
-the asteroids above. The asteroids are set to a main asteroid clock that shoots the asteroids in increasingly difficult speeds. With a random number generator, an element of unpredictability is added as well. At the same time, obstacles such as satellites will be moving horizontally across the screen. These will block your fire as well as your movement. However, there will be powerups that may spawn that you'll only have to shoot to acquire! +
- +
- +
-==Point System== +
-  * Destroyed asteroid+10 +
-  * Missed missile: ​-+
-  * Damaged satellite-10 +
-  * (Co-op)Damaged opposing player: +5 +
- +
-==Game Mode== +
-  * 2 player allows the game to have 3 separate game modes: +
-  * Classic 1 player run to save the world! +
-  * 2 player versus: The 2nd player plays as an aggressive space invader with the quest to annihilate Earth. +
-  * 2 player co-op: The 2nd player assists the 1st by joining the fray to protect humanity. +
- +
-==power-up types== +
-  - Shot delay decrease +
-  - screen clear +
-  - ship speed increase +
-  - Heals +
-=====Bug Corner===== +
- +
-Post bugs here, either debugged bugs that you feel might pop up for others, or current bugs pending debugging. +
- +
-====Generic Bugs==== +
- +
-Found a bug with hit detection. +
- +
-When checking Input1 for Player1, cannot reference arithmetic regarding player2. +
- +
-An example would be: +
- +
-<​code>​player1.x > player2.x + SPRITE_WIDTH</​code>​ +
- +
-This will soft-lock the game upon running an if-statement containing this. However: +
- +
-<​code>​player1.x ​SPRITE_WIDTH > player2.x</​code>​ +
- +
-will work, and is identical in functionality. Will report back if I figure out the exact problem, and if it will work the same way with Player2'​s collision detection. +
- +
-====Game Specific Bugs==== +
- +
-=====Programming Considerations===== +
-Due to the restrictive nature of the NES hardware, some "​common sense" programming optimizations we would usually make are impractical here. +
- +
-For example: arrays. For NES programming,​ especially when dealing with lots of sprites, it seems counter-intuitive, but we may want to avoid using arrays, because it actually causes a lot more work for the 6502 CPU in the NES. See this forum post for some further explanation (and some other solutions):​ +
- +
-  * https://​forums.nesdev.com/​viewtopic.php?​f=2&​t=17465&​start=0 +
- +
-We have to remember: NES programming,​ even with the benefit of C, is NOT going to be a clean, efficient endeavor. There will be messiness. This is but one example. +
- +
-Some related resources talking about programming considerations due to the hardware: +
- +
-  * https://​news.ycombinator.com/​item?​id=15002510 +
-  * https://​shiru.untergrund.net/​articles/​programming_nes_games_in_c.htm +
- +
-===Variables=== +
-Due to the limitations of the hardware, making variables as small as possible is a common consideration. Many read/write variables, such as the X/Y coordinates of sprites, use the "​uint8_t"​ variable type, which corresponds to an "​unsigned char" under normal circumstances. Make note of the variable'​s maximum and minimum values, as overflows and underflows can go undetected. +
-======Login Problems====== +
-Some people have reported problems logging into the wiki. There seems to be two sources of problems experienced:​ +
- +
-  * User cannot log in. +
-  * User cannot log in using "​Secure Login"​. +
- +
-If you are confident you are using the correct username and password, and are using a version of Internet Explorer, it is suggested that you use a different browser, such as Firefox, Safari, or Chrome. +
- +
-If the "​Secure Login" doesn'​t seem to be working for you, the behavior seems to occur when user passwords contain symbols like quote marks and asterisks. In which case, you can either: +
- +
-  * Uncheck "Use Secure Login"​. This sort of defeats the purpose of having security though, so it isn't outwardly recommended. +
-  * Change your password to something that doesn'​t contain quote marks or asterisks. We don't yet know **exactly** which characters cause this problem, but we suspect it is characters that aren't being properly escaped that could have special syntactical meaning.+
  
-======Syntax====== +Atari Programming for Newbies: ​[[https://​www.randomterrain.com/​atari-2600-memories-tutorial-andrew-davie-01.html ​Link]]\\ 
-For those unfamiliar, here is a page on [[wiki:syntax|wiki editing syntax]] that can be used here.+Stella'​s Programming Guide: [[https://​alienbill.com/​2600/​101/​docs/​stella.html#​tvprot | Link]]
  
-=====DokuWiki wrap plugin===== +=====Cycle Ranges=====
-http://​www.dokuwiki.org/​_media/​plugin:​wrap_plugin_example2.png+
notes/comporg.1557411048.txt.gz · Last modified: 2019/05/09 10:10 by jwilli57