Jump to content

Image noise: Difference between revisions

m
→‎{{header|Z80 Assembly}}: typo fix and clarification
m (→‎{{header|Z80 Assembly}}: typo fix and clarification)
Line 3,202:
rrca
rrca
xor (hl) ;crude xorshift rng used to select a "random" location to draw to.
 
ld h,0
ld L,a ;this random value becomes the low byte of HL
 
rlc L
rl h ;reduce the RNG's bias towards the top of the screen by shifting one bit into H.
ld a,&98 ;high byte of gb vram
add h ;h will equal either 0 or 1.
ld H,a ;now H will either equal &98 or &99
ld a,(frametimer) ;it's possible that this value is different from before since every vblank it increments.
Line 3,225:
wait:
halt ;waits for an interrupt.
cp (hl) ;compare 0 to vblankflag
jr z,wait ;vblank flag is still 1 so keep waiting.
ld (hl),a ;clear vblank flag.
Line 3,257:
And the interrupt handler located at memory address <code>&A000</code>:
<lang z80>TV_Static_FX:
;this code runs every time the game boy finishes drawing one row of pixels, unless the interrupt is disabled as described above.
push hl
push af
ld hl,(COSINE_INDEX)
inc (hl)
ld a,(hl)
Line 3,268 ⟶ 3,269:
; returns cos(A) into A
 
LDHLD (&43FF43),A ;output Acos(frametimer) to horizontal scroll register.
done_TV_Static_FX:
pop af
pop hl
reti ;return to main program
TV_Static_FX_End:</lang>
 
1,489

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.