Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
58
Task/Image-noise/Z80-Assembly/image-noise-1.z80
Normal file
58
Task/Image-noise/Z80-Assembly/image-noise-1.z80
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
forever:
|
||||
ld hl,frametimer
|
||||
ld a,(hl)
|
||||
rrca
|
||||
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.
|
||||
;the vblank code was omitted because it's mostly irrelevant to the task.
|
||||
and &0f ;select one of sixteen tiles to draw to the screen at the randomly chosen VRAM location.
|
||||
call LCDWait ;disable interrupts, and wait until the Game Boy is ready to update the tilemap
|
||||
ei ;enable interrupts again.
|
||||
ld (hl),a ;now we can store the frame timer AND &0F into video ram.
|
||||
|
||||
|
||||
ld hl,vblankflag ;set to 1 by the vblank routine.
|
||||
xor a
|
||||
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.
|
||||
|
||||
|
||||
ld hl,&FFFF ;master interrupt register
|
||||
res 1,(hl) ;disable hblank interrupt.
|
||||
|
||||
ld bc,2
|
||||
ld a,(frametimer)
|
||||
bit 4,a ;check bit 4 of frametimer, if zero, we'll do sine instead of cosine. Bit 4 was chosen arbitrarily.
|
||||
jr nz,doSine
|
||||
ld hl,cos
|
||||
jr nowStore
|
||||
doSine:
|
||||
ld hl,sin
|
||||
nowStore: ;store desired routine as the CALL address
|
||||
ld a,L
|
||||
LD (&A000+(callpoint-TV_Static_FX+1)),a
|
||||
;using label arithmetic we can work out the place to modify the code.
|
||||
;hblank interrupt immediately jumps to cartridge RAM at &A000
|
||||
ld a,H
|
||||
LD (&A000+(callpoint-TV_Static_FX+2)),a ;store the high byte.
|
||||
|
||||
ld hl,&FFFF
|
||||
set 1,(hl) ;re-enable hblank interrupt
|
||||
|
||||
|
||||
jp forever
|
||||
19
Task/Image-noise/Z80-Assembly/image-noise-2.z80
Normal file
19
Task/Image-noise/Z80-Assembly/image-noise-2.z80
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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)
|
||||
|
||||
callpoint:
|
||||
call cos ;<--- SMC, gets changed to "CALL SIN" by main game loop when bit 4 of frametimer equals 0, and back to
|
||||
;"CALL COS" when bit 4 of frametimer equals 1.
|
||||
; returns cos(A) into A
|
||||
|
||||
LD (&FF43),A ;output cos(frametimer) to horizontal scroll register
|
||||
done_TV_Static_FX:
|
||||
pop af
|
||||
pop hl
|
||||
reti ;return to main program
|
||||
TV_Static_FX_End:
|
||||
Loading…
Add table
Add a link
Reference in a new issue