Instructor Notes
March 3, 2008
Assignment Reminders
- Initial Term Project Proposal: due March 9 midnight (discussion)
- Midterm: March 12 (discussion)
- Hello Noise: March 25th
focus on sound effects for the games, not the music i.e. handing in Lemon Player is not going to fly.
Quote
"Engineering problems are under-defined, there are many solutions, good, bad and indifferent. The art is to arrive at a good solution. This is a creative activity, involving imagination, intuition and deliberate choice." -- Ove Arup
Hello GameBoy and Hello Sprite projects
Feedback
- delay routine doesn't look at c
- no value given to bc before calling delay
- hard-coding one character at a time
- more comments in your code
- put your name on your code!
Examples
Alec's Code:
- 97 - 101 should be a routine or a macro...
- 2nd and 3rd dot are hard-coded...
call BigLoop. What happens to SP?
- how can the code take input at any time instead of just before printing "loading"?
gbspec example: lines 574-608:
; **** Main Game Loop **** Main: halt ; stop system clock ; return from halt when interrupted nop ; (See WARNING above.) ld a,(VblnkFlag) or a ; V-Blank interrupt ? jr z,Main ; No, some other interrupt xor a ld (VblnkFlag),a ; Clear V-Blank flag call Controls ; button inputs call Game ; game operation jr Main ; **** V-Blank Interrupt Routine **** Vblnk: push af push bc push de push hl call SpriteDma ; Do sprite updates ld a,1 ld (VblnkFlag),a pop hl pop de pop bc pop af reti
Tien's Code:
- delay loops 442-460
- do a variable to demonstrate?
Look at some Hello Sprite projects
- Daniel Schossow?
- understanding the never-ending loop --- purpose etc.
- Tommy
- music concurrently with whatever is happening in your game etc.
Z80 wrapup-part I
- addressing modes (page 44 of Z80 user's manual)
- Immediate: opcode and 1 byte
- Immediate extended: opcode and 2 byte data
- Modified Page 0 Addressing: (b5 b4 b3 0 0 0)
- Relative Addressing
- Extended Addressing: and 2 byte address
Indexed Addressing: not used on GameBoy. on Z80 offers displacement to IX or IY
- Register Addressing:
- Implied Addressing: register is implied
- Register Indirect Addressing: pointer to location in memory
- Bit Addressing
how does the assembler assemble? From http://www.nersc.gov/vendor_docs/ibm/asm/assembler_passes.htm
- First Pass
- Checks to see if the instructions are legal in the current assembly mode.
- Allocates space for instructions and storage areas you request.
- Fills in the values of constants, where possible.
- Builds a symbol table, also called a cross-reference table, and makes an entry in this table for every symbol it encounters in the label field of a statement.
- Second Pass
- Examines the operands for symbolic references to storage locations and resolves these symbolic references using information in the symbol table.
- Ensures that no instructions contain an invalid instruction form.
- Translates source statements into machine code and constants, thus filling the allocated space with object code.
- Produces a file containing error messages, if any have occurred.
- First Pass
- timing (T cycles, M cycles) (Z80 manual page 80)
- 1 T cycle is 1/f of clock
- each machines cycle is one of
- 1st is always "fetch" which is 4-6 T cycles long
- subsequent M cycles move data to or from memory
- see page 12 of z80 manual
- instruction types (see Z80 manual page vi)
- 8 bit load group
- 16 bit load group
- exchange, block transfer, and search group
- 8 bit arithmetic group
- DAA
- note addressing mode
- general-purpose arithmetic and CPU control
- 16 bit arithmetic group
- rotate and shift group
- bit set, reset, and test group
- jump group
- call and return group
- input and output group
differences between Z80 and GameBoy
gbspec lines 60-90:
The following are added instructions: ADD SP,nn ;nn = signed byte LD (HLI),A ;Write A to (HL) and increment HL LD (HLD),A ;Write A to (HL) and decrement HL LD A,(HLI) ;Write (HL) to A and increment HL LD A,(HLD) ;Write (HL) to A and decrement HL LD A,($FF00+nn) LD A,($FF00+C) LD ($FF00+nn),A LD ($FF00+C),A LD (nnnn),SP LD HL,SP+nn ;nn = signed byte STOP ;Stop processor & screen until button press SWAP r ;Swap high & low nibbles of r The following instructions have been removed: Any command that uses the IX or IY registers. All IN/OUT instructions. All exchange instructions. All commands prefixed by ED (except remapped RETI). All conditional jumps/calls/rets on parity/overflow and sign flag. The following instructions have different opcodes: LD A,[nnnn] LD [nnnn],A RETI